Skip to content

Commit a587f8d

Browse files
committed
add gl2d visible toggle jasmine test
1 parent 2563f17 commit a587f8d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/jasmine/tests/gl_plot_interact_test.js

+33
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,39 @@ describe('Test gl plot interactions', function() {
331331

332332
}, MODEBAR_DELAY);
333333
});
334+
335+
it('should be able to toggle visibility', function(done) {
336+
var OBJECT_PER_TRACE = 5;
337+
338+
var objects = function() {
339+
return gd._fullLayout._plots.xy._scene2d.glplot.objects;
340+
};
341+
342+
expect(objects().length).toEqual(OBJECT_PER_TRACE);
343+
344+
Plotly.restyle(gd, 'visible', 'legendonly').then(function() {
345+
expect(objects().length).toEqual(OBJECT_PER_TRACE);
346+
expect(objects()[0].data.length).toEqual(0);
347+
348+
return Plotly.restyle(gd, 'visible', true);
349+
})
350+
.then(function() {
351+
expect(objects().length).toEqual(OBJECT_PER_TRACE);
352+
expect(objects()[0].data.length).not.toEqual(0);
353+
354+
return Plotly.restyle(gd, 'visible', false);
355+
})
356+
.then(function() {
357+
expect(gd._fullLayout._plots.xy._scene2d).toBeUndefined();
358+
359+
return Plotly.restyle(gd, 'visible', true);
360+
})
361+
.then(function() {
362+
expect(objects().length).toEqual(OBJECT_PER_TRACE);
363+
expect(objects()[0].data.length).not.toEqual(0);
364+
})
365+
.then(done);
366+
});
334367
});
335368

336369
describe('gl3d event handlers', function() {

0 commit comments

Comments
 (0)