Skip to content

Commit 4af6528

Browse files
committed
adapt and improve scattergl visible toggle tests
1 parent f1f06f4 commit 4af6528

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

test/jasmine/tests/cartesian_test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,17 @@ describe('restyle', function() {
194194
})
195195
.then(function() {
196196
expect(!!gd._fullLayout._plots.x2y2._scene).toBe(true);
197+
expect(gd._fullLayout._plots.x2y2._scene.visibleBatch).toEqual([0]);
197198
return Plotly.restyle(gd, {visible: 'legendonly'}, 1);
198199
})
199200
.then(function() {
200-
expect(!!gd._fullLayout._plots.x2y2._scene).toBe(false);
201+
expect(!!gd._fullLayout._plots.x2y2._scene).toBe(true);
202+
expect(gd._fullLayout._plots.x2y2._scene.visibleBatch).toEqual([]);
201203
return Plotly.restyle(gd, {visible: true}, 1);
202204
})
203205
.then(function() {
204206
expect(!!gd._fullLayout._plots.x2y2._scene).toBe(true);
207+
expect(gd._fullLayout._plots.x2y2._scene.visibleBatch).toEqual([0]);
205208
})
206209
.catch(failTest)
207210
.then(done);

test/jasmine/tests/gl2d_plot_interact_test.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -358,27 +358,38 @@ describe('@gl Test gl2d plots', function() {
358358
var _mock = Lib.extendDeep({}, mock);
359359
_mock.data[0].line.width = 5;
360360

361+
function assertDrawCall(msg, exp) {
362+
var draw = gd._fullLayout._plots.xy._scene.scatter2d.draw;
363+
expect(draw).toHaveBeenCalledTimes(exp, msg);
364+
draw.calls.reset();
365+
}
366+
361367
Plotly.plot(gd, _mock)
362368
.then(delay(30))
363369
.then(function() {
370+
spyOn(gd._fullLayout._plots.xy._scene.scatter2d, 'draw');
364371
return Plotly.restyle(gd, 'visible', 'legendonly');
365372
})
366373
.then(function() {
367-
expect(gd.querySelector('.gl-canvas-context')).toBe(null);
374+
expect(readPixel(gd.querySelector('.gl-canvas-context'), 108, 100)[0]).toBe(0);
375+
assertDrawCall('legendonly', 0);
368376

369377
return Plotly.restyle(gd, 'visible', true);
370378
})
371379
.then(function() {
372380
expect(readPixel(gd.querySelector('.gl-canvas-context'), 108, 100)[0]).not.toBe(0);
381+
assertDrawCall('back to visible', 1);
373382

374383
return Plotly.restyle(gd, 'visible', false);
375384
})
376385
.then(function() {
377-
expect(gd.querySelector('.gl-canvas-context')).toBe(null);
386+
expect(readPixel(gd.querySelector('.gl-canvas-context'), 108, 100)[0]).toBe(0);
387+
assertDrawCall('visible false', 0);
378388

379389
return Plotly.restyle(gd, 'visible', true);
380390
})
381391
.then(function() {
392+
assertDrawCall('back up', 1);
382393
expect(readPixel(gd.querySelector('.gl-canvas-context'), 108, 100)[0]).not.toBe(0);
383394
})
384395
.catch(failTest)

0 commit comments

Comments
 (0)