Skip to content

Commit 310e67a

Browse files
committedMay 11, 2017
add test case for point / text node removal on blank data
1 parent 6653e71 commit 310e67a

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
 

‎test/jasmine/tests/scatter_test.js

+54
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,60 @@ describe('end-to-end scatter tests', function() {
383383
expect(Plotly.d3.selectAll('.textpoint').size()).toBe(3);
384384
}).catch(fail).then(done);
385385
});
386+
387+
it('should remove all point and text nodes on blank data', function(done) {
388+
function assertNodeCnt(ptCnt, txCnt) {
389+
expect(d3.selectAll('.point').size()).toEqual(ptCnt);
390+
expect(d3.selectAll('.textpoint').size()).toEqual(txCnt);
391+
}
392+
393+
function assertText(content) {
394+
d3.selectAll('.textpoint').each(function(_, i) {
395+
var tx = d3.select(this).select('text');
396+
expect(tx.text()).toEqual(content[i]);
397+
});
398+
}
399+
400+
Plotly.plot(gd, [{
401+
x: [150, 350, 650],
402+
y: [100, 300, 600],
403+
text: ['A', 'B', 'C'],
404+
mode: 'markers+text',
405+
marker: {
406+
size: [100, 200, 300],
407+
line: { width: [10, 20, 30] },
408+
color: 'yellow',
409+
sizeref: 3,
410+
gradient: {
411+
type: 'radial',
412+
color: 'white'
413+
}
414+
}
415+
}])
416+
.then(function() {
417+
assertNodeCnt(3, 3);
418+
assertText(['A', 'B', 'C']);
419+
420+
return Plotly.restyle(gd, {
421+
x: [[null, undefined, NaN]],
422+
y: [[NaN, null, undefined]]
423+
});
424+
})
425+
.then(function() {
426+
assertNodeCnt(0, 0);
427+
428+
return Plotly.restyle(gd, {
429+
x: [[150, 350, 650]],
430+
y: [[100, 300, 600]]
431+
});
432+
})
433+
.then(function() {
434+
assertNodeCnt(3, 3);
435+
assertText(['A', 'B', 'C']);
436+
})
437+
.catch(fail)
438+
.then(done);
439+
});
386440
});
387441

388442
describe('scatter hoverPoints', function() {

0 commit comments

Comments
 (0)
Please sign in to comment.