Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab96422

Browse files
committed
test: check clip path & dragger counts in cartesian plots
1 parent f4aee1e commit ab96422

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

test/jasmine/tests/plot_interact_test.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ describe('Test plot structure', function() {
3737
return d3.selectAll('rect.cbbg').size();
3838
}
3939

40+
function countClipPaths() {
41+
return d3.selectAll('defs').selectAll('.axesclip,.plotclip').size();
42+
}
43+
44+
function countDraggers() {
45+
return d3.selectAll('g.draglayer').selectAll('g').size();
46+
}
47+
4048
describe('scatter traces', function() {
4149
var mock = require('@mocks/14.json');
4250
var gd;
@@ -54,6 +62,14 @@ describe('Test plot structure', function() {
5462
expect(countSubplots()).toEqual(1);
5563
});
5664

65+
it('has four clip paths', function() {
66+
expect(countClipPaths()).toEqual(4);
67+
});
68+
69+
it('has one dragger group', function() {
70+
expect(countDraggers()).toEqual(1);
71+
});
72+
5773
it('has one *scatterlayer* node', function() {
5874
var nodes = d3.selectAll('g.scatterlayer');
5975
expect(nodes.size()).toEqual(1);
@@ -90,11 +106,15 @@ describe('Test plot structure', function() {
90106
Plotly.deleteTraces(gd, [0]).then(function() {
91107
expect(countScatterTraces()).toEqual(0);
92108
expect(countSubplots()).toEqual(1);
109+
expect(countClipPaths()).toEqual(4);
110+
expect(countDraggers()).toEqual(1);
93111

94112
return Plotly.relayout(gd, {xaxis: null, yaxis: null});
95113
}).then(function() {
96114
expect(countScatterTraces()).toEqual(0);
97115
expect(countSubplots()).toEqual(0);
116+
expect(countClipPaths()).toEqual(0);
117+
expect(countDraggers()).toEqual(0);
98118

99119
done();
100120
});
@@ -302,6 +322,8 @@ describe('Test plot structure', function() {
302322

303323
it('has four *subplot* nodes', function() {
304324
expect(countSubplots()).toEqual(4);
325+
expect(countClipPaths()).toEqual(12);
326+
expect(countDraggers()).toEqual(4);
305327
});
306328

307329
it('has four heatmap image nodes', function() {
@@ -340,6 +362,8 @@ describe('Test plot structure', function() {
340362

341363
it('has four *subplot* nodes', function() {
342364
expect(countSubplots()).toEqual(4);
365+
expect(countClipPaths()).toEqual(12);
366+
expect(countDraggers()).toEqual(4);
343367
});
344368

345369
it('has two heatmap image nodes', function() {
@@ -376,27 +400,51 @@ describe('Test plot structure', function() {
376400

377401
Plotly.deleteTraces(gd, [0]).then(function() {
378402
expect(countSubplots()).toEqual(4);
403+
expect(countClipPaths()).toEqual(12);
404+
expect(countDraggers()).toEqual(4);
379405
assertHeatmapNodes(3);
380406
assertContourNodes(2);
381407
expect(countColorBars()).toEqual(0);
382408

383409
return Plotly.deleteTraces(gd, [0]);
384410
}).then(function() {
385411
expect(countSubplots()).toEqual(4);
412+
expect(countClipPaths()).toEqual(12);
413+
expect(countDraggers()).toEqual(4);
386414
assertHeatmapNodes(2);
387415
assertContourNodes(2);
388416
expect(countColorBars()).toEqual(0);
389417

390418
return Plotly.deleteTraces(gd, [0]);
391419
}).then(function() {
392420
expect(countSubplots()).toEqual(4);
421+
expect(countClipPaths()).toEqual(12);
422+
expect(countDraggers()).toEqual(4);
393423
assertHeatmapNodes(1);
394424
assertContourNodes(1);
395425
expect(countColorBars()).toEqual(0);
396426

397427
return Plotly.deleteTraces(gd, [0]);
398428
}).then(function() {
399429
expect(countSubplots()).toEqual(3);
430+
expect(countClipPaths()).toEqual(11);
431+
expect(countDraggers()).toEqual(3);
432+
assertHeatmapNodes(0);
433+
assertContourNodes(0);
434+
expect(countColorBars()).toEqual(0);
435+
436+
var update = {
437+
xaxis: null,
438+
yaxis: null,
439+
xaxis2: null,
440+
yaxis2: null
441+
};
442+
443+
return Plotly.relayout(gd, update);
444+
}).then(function() {
445+
expect(countSubplots()).toEqual(0);
446+
expect(countClipPaths()).toEqual(0);
447+
expect(countDraggers()).toEqual(0);
400448
assertHeatmapNodes(0);
401449
assertContourNodes(0);
402450
expect(countColorBars()).toEqual(0);

0 commit comments

Comments
 (0)