Skip to content

Commit 10ffd1e

Browse files
committed
test: add cases for restyle( 'mode', '*')
1 parent ce762e8 commit 10ffd1e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/jasmine/tests/cartesian_test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,52 @@ describe('restyle', function() {
150150
expect(firstLine2).toBe(secondLine2);
151151
}).then(done);
152152
});
153+
154+
it('can change scatter mode', function(done) {
155+
var mock = Lib.extendDeep({}, require('@mocks/text_chart_basic.json'));
156+
157+
function assertScatterModeSizes(lineSize, pointSize, textSize) {
158+
var gd3 = d3.select(gd),
159+
lines = gd3.selectAll('g.scatter.trace .js-line'),
160+
points = gd3.selectAll('g.scatter.trace path.point'),
161+
texts = gd3.selectAll('g.scatter.trace text');
162+
163+
expect(lines.size()).toEqual(lineSize);
164+
expect(points.size()).toEqual(pointSize);
165+
expect(texts.size()).toEqual(textSize);
166+
}
167+
168+
Plotly.plot(gd, mock.data, mock.layout).then(function() {
169+
assertScatterModeSizes(2, 6, 9);
170+
171+
return Plotly.restyle(gd, 'mode', 'lines');
172+
})
173+
.then(function() {
174+
assertScatterModeSizes(3, 0, 0);
175+
176+
return Plotly.restyle(gd, 'mode', 'markers');
177+
})
178+
.then(function() {
179+
assertScatterModeSizes(0, 9, 0);
180+
181+
return Plotly.restyle(gd, 'mode', 'markers+text');
182+
})
183+
.then(function() {
184+
assertScatterModeSizes(0, 9, 9);
185+
186+
return Plotly.restyle(gd, 'mode', 'text');
187+
})
188+
.then(function() {
189+
assertScatterModeSizes(0, 0, 9);
190+
191+
return Plotly.restyle(gd, 'mode', 'markers+text+lines');
192+
})
193+
.then(function() {
194+
assertScatterModeSizes(3, 9, 9);
195+
})
196+
.then(done);
197+
198+
});
153199
});
154200
});
155201

0 commit comments

Comments
 (0)