Skip to content

Commit b23d2ff

Browse files
committed
[spacing][technical] just wrapping around test case in anticipation of more cases inside
1 parent 02742e8 commit b23d2ff

File tree

1 file changed

+143
-139
lines changed

1 file changed

+143
-139
lines changed

test/jasmine/tests/transform_groupby_test.js

Lines changed: 143 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -10,172 +10,176 @@ Plotly.register([
1010
require('@src/transforms/groupby')
1111
]);
1212

13-
describe('one-to-many transforms:', function() {
14-
'use strict';
15-
16-
var mockData0 = [{
17-
mode: 'markers',
18-
x: [1, -1, -2, 0, 1, 2, 3],
19-
y: [1, 2, 3, 1, 2, 3, 1],
20-
transforms: [{
21-
type: 'groupby',
22-
groups: ['a', 'a', 'b', 'a', 'b', 'b', 'a'],
23-
style: { a: {marker: {color: 'red'}}, b: {marker: {color: 'blue'}} }
24-
}]
25-
}];
26-
27-
var mockData1 = [Lib.extendDeep({}, mockData0[0]), {
28-
mode: 'markers',
29-
x: [20, 11, 12, 0, 1, 2, 3],
30-
y: [1, 2, 3, 2, 5, 2, 0],
31-
transforms: [{
32-
type: 'groupby',
33-
groups: ['b', 'a', 'b', 'b', 'b', 'a', 'a'],
34-
style: { a: {marker: {color: 'green'}}, b: {marker: {color: 'black'}} }
35-
}]
36-
}];
37-
38-
afterEach(destroyGraphDiv);
39-
40-
it('Plotly.plot should plot the transform traces', function(done) {
41-
var data = Lib.extendDeep([], mockData0);
42-
43-
var gd = createGraphDiv();
44-
45-
Plotly.plot(gd, data).then(function() {
46-
expect(gd.data.length).toEqual(1);
47-
expect(gd.data[0].x).toEqual([1, -1, -2, 0, 1, 2, 3]);
48-
expect(gd.data[0].y).toEqual([1, 2, 3, 1, 2, 3, 1]);
49-
50-
expect(gd._fullData.length).toEqual(2);
51-
expect(gd._fullData[0].x).toEqual([1, -1, 0, 3]);
52-
expect(gd._fullData[0].y).toEqual([1, 2, 1, 1]);
53-
expect(gd._fullData[1].x).toEqual([-2, 1, 2]);
54-
expect(gd._fullData[1].y).toEqual([3, 2, 3]);
55-
56-
assertDims([4, 3]);
57-
58-
done();
13+
describe('groupby', function() {
14+
15+
describe('one-to-many transforms:', function() {
16+
'use strict';
17+
18+
var mockData0 = [{
19+
mode: 'markers',
20+
x: [1, -1, -2, 0, 1, 2, 3],
21+
y: [1, 2, 3, 1, 2, 3, 1],
22+
transforms: [{
23+
type: 'groupby',
24+
groups: ['a', 'a', 'b', 'a', 'b', 'b', 'a'],
25+
style: { a: {marker: {color: 'red'}}, b: {marker: {color: 'blue'}} }
26+
}]
27+
}];
28+
29+
var mockData1 = [Lib.extendDeep({}, mockData0[0]), {
30+
mode: 'markers',
31+
x: [20, 11, 12, 0, 1, 2, 3],
32+
y: [1, 2, 3, 2, 5, 2, 0],
33+
transforms: [{
34+
type: 'groupby',
35+
groups: ['b', 'a', 'b', 'b', 'b', 'a', 'a'],
36+
style: { a: {marker: {color: 'green'}}, b: {marker: {color: 'black'}} }
37+
}]
38+
}];
39+
40+
afterEach(destroyGraphDiv);
41+
42+
it('Plotly.plot should plot the transform traces', function(done) {
43+
var data = Lib.extendDeep([], mockData0);
44+
45+
var gd = createGraphDiv();
46+
47+
Plotly.plot(gd, data).then(function() {
48+
expect(gd.data.length).toEqual(1);
49+
expect(gd.data[0].x).toEqual([1, -1, -2, 0, 1, 2, 3]);
50+
expect(gd.data[0].y).toEqual([1, 2, 3, 1, 2, 3, 1]);
51+
52+
expect(gd._fullData.length).toEqual(2);
53+
expect(gd._fullData[0].x).toEqual([1, -1, 0, 3]);
54+
expect(gd._fullData[0].y).toEqual([1, 2, 1, 1]);
55+
expect(gd._fullData[1].x).toEqual([-2, 1, 2]);
56+
expect(gd._fullData[1].y).toEqual([3, 2, 3]);
57+
58+
assertDims([4, 3]);
59+
60+
done();
61+
});
5962
});
60-
});
6163

62-
it('Plotly.restyle should work', function(done) {
63-
var data = Lib.extendDeep([], mockData0);
64-
data[0].marker = { size: 20 };
65-
66-
var gd = createGraphDiv();
67-
var dims = [4, 3];
68-
69-
Plotly.plot(gd, data).then(function() {
70-
assertStyle(dims,
71-
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
72-
[1, 1]
73-
);
74-
75-
return Plotly.restyle(gd, 'marker.opacity', 0.4);
76-
}).then(function() {
77-
assertStyle(dims,
78-
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
79-
[0.4, 0.4]
80-
);
81-
82-
expect(gd._fullData[0].marker.opacity).toEqual(0.4);
83-
expect(gd._fullData[1].marker.opacity).toEqual(0.4);
84-
85-
return Plotly.restyle(gd, 'marker.opacity', 1);
86-
}).then(function() {
87-
assertStyle(dims,
88-
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
89-
[1, 1]
90-
);
91-
92-
expect(gd._fullData[0].marker.opacity).toEqual(1);
93-
expect(gd._fullData[1].marker.opacity).toEqual(1);
94-
95-
return Plotly.restyle(gd, {
96-
'transforms[0].style': { a: {marker: {color: 'green'}}, b: {marker: {color: 'red'}} },
97-
'marker.opacity': 0.4
64+
it('Plotly.restyle should work', function(done) {
65+
var data = Lib.extendDeep([], mockData0);
66+
data[0].marker = { size: 20 };
67+
68+
var gd = createGraphDiv();
69+
var dims = [4, 3];
70+
71+
Plotly.plot(gd, data).then(function() {
72+
assertStyle(dims,
73+
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
74+
[1, 1]
75+
);
76+
77+
return Plotly.restyle(gd, 'marker.opacity', 0.4);
78+
}).then(function() {
79+
assertStyle(dims,
80+
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
81+
[0.4, 0.4]
82+
);
83+
84+
expect(gd._fullData[0].marker.opacity).toEqual(0.4);
85+
expect(gd._fullData[1].marker.opacity).toEqual(0.4);
86+
87+
return Plotly.restyle(gd, 'marker.opacity', 1);
88+
}).then(function() {
89+
assertStyle(dims,
90+
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
91+
[1, 1]
92+
);
93+
94+
expect(gd._fullData[0].marker.opacity).toEqual(1);
95+
expect(gd._fullData[1].marker.opacity).toEqual(1);
96+
97+
return Plotly.restyle(gd, {
98+
'transforms[0].style': { a: {marker: {color: 'green'}}, b: {marker: {color: 'red'}} },
99+
'marker.opacity': 0.4
100+
});
101+
}).then(function() {
102+
assertStyle(dims,
103+
['rgb(0, 128, 0)', 'rgb(255, 0, 0)'],
104+
[0.4, 0.4]
105+
);
106+
107+
done();
98108
});
99-
}).then(function() {
100-
assertStyle(dims,
101-
['rgb(0, 128, 0)', 'rgb(255, 0, 0)'],
102-
[0.4, 0.4]
103-
);
104-
105-
done();
106109
});
107-
});
108110

109-
it('Plotly.extendTraces should work', function(done) {
110-
var data = Lib.extendDeep([], mockData0);
111+
it('Plotly.extendTraces should work', function(done) {
112+
var data = Lib.extendDeep([], mockData0);
111113

112-
var gd = createGraphDiv();
114+
var gd = createGraphDiv();
113115

114-
Plotly.plot(gd, data).then(function() {
115-
expect(gd.data[0].x.length).toEqual(7);
116-
expect(gd._fullData[0].x.length).toEqual(4);
117-
expect(gd._fullData[1].x.length).toEqual(3);
116+
Plotly.plot(gd, data).then(function() {
117+
expect(gd.data[0].x.length).toEqual(7);
118+
expect(gd._fullData[0].x.length).toEqual(4);
119+
expect(gd._fullData[1].x.length).toEqual(3);
118120

119-
assertDims([4, 3]);
121+
assertDims([4, 3]);
120122

121-
return Plotly.extendTraces(gd, {
122-
x: [ [-3, 4, 5] ],
123-
y: [ [1, -2, 3] ],
124-
'transforms[0].groups': [ ['b', 'a', 'b'] ]
125-
}, [0]);
126-
}).then(function() {
127-
expect(gd.data[0].x.length).toEqual(10);
128-
expect(gd._fullData[0].x.length).toEqual(5);
129-
expect(gd._fullData[1].x.length).toEqual(5);
123+
return Plotly.extendTraces(gd, {
124+
x: [ [-3, 4, 5] ],
125+
y: [ [1, -2, 3] ],
126+
'transforms[0].groups': [ ['b', 'a', 'b'] ]
127+
}, [0]);
128+
}).then(function() {
129+
expect(gd.data[0].x.length).toEqual(10);
130+
expect(gd._fullData[0].x.length).toEqual(5);
131+
expect(gd._fullData[1].x.length).toEqual(5);
130132

131-
assertDims([5, 5]);
133+
assertDims([5, 5]);
132134

133-
done();
135+
done();
136+
});
134137
});
135-
});
136138

137-
it('Plotly.deleteTraces should work', function(done) {
138-
var data = Lib.extendDeep([], mockData1);
139+
it('Plotly.deleteTraces should work', function(done) {
140+
var data = Lib.extendDeep([], mockData1);
139141

140-
var gd = createGraphDiv();
142+
var gd = createGraphDiv();
141143

142-
Plotly.plot(gd, data).then(function() {
143-
assertDims([4, 3, 4, 3]);
144+
Plotly.plot(gd, data).then(function() {
145+
assertDims([4, 3, 4, 3]);
144146

145-
return Plotly.deleteTraces(gd, [1]);
146-
}).then(function() {
147-
assertDims([4, 3]);
147+
return Plotly.deleteTraces(gd, [1]);
148+
}).then(function() {
149+
assertDims([4, 3]);
148150

149-
return Plotly.deleteTraces(gd, [0]);
150-
}).then(function() {
151-
assertDims([]);
151+
return Plotly.deleteTraces(gd, [0]);
152+
}).then(function() {
153+
assertDims([]);
152154

153-
done();
155+
done();
156+
});
154157
});
155-
});
156158

157-
it('toggling trace visibility should work', function(done) {
158-
var data = Lib.extendDeep([], mockData1);
159+
it('toggling trace visibility should work', function(done) {
160+
var data = Lib.extendDeep([], mockData1);
159161

160-
var gd = createGraphDiv();
162+
var gd = createGraphDiv();
161163

162-
Plotly.plot(gd, data).then(function() {
163-
assertDims([4, 3, 4, 3]);
164+
Plotly.plot(gd, data).then(function() {
165+
assertDims([4, 3, 4, 3]);
164166

165-
return Plotly.restyle(gd, 'visible', 'legendonly', [1]);
166-
}).then(function() {
167-
assertDims([4, 3]);
167+
return Plotly.restyle(gd, 'visible', 'legendonly', [1]);
168+
}).then(function() {
169+
assertDims([4, 3]);
168170

169-
return Plotly.restyle(gd, 'visible', false, [0]);
170-
}).then(function() {
171-
assertDims([]);
171+
return Plotly.restyle(gd, 'visible', false, [0]);
172+
}).then(function() {
173+
assertDims([]);
172174

173-
return Plotly.restyle(gd, 'visible', [true, true], [0, 1]);
174-
}).then(function() {
175-
assertDims([4, 3, 4, 3]);
175+
return Plotly.restyle(gd, 'visible', [true, true], [0, 1]);
176+
}).then(function() {
177+
assertDims([4, 3, 4, 3]);
176178

177-
done();
179+
done();
180+
});
178181
});
182+
179183
});
180184

181185
});

0 commit comments

Comments
 (0)