Skip to content

Commit cbcec26

Browse files
committed
add failing test cases showcasing issue #1706
1 parent cea9455 commit cbcec26

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

test/jasmine/tests/scatter_test.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,108 @@ describe('end-to-end scatter tests', function() {
437437
.catch(fail)
438438
.then(done);
439439
});
440+
441+
function _assertNodes(ptStyle, txContent) {
442+
var pts = d3.selectAll('.point');
443+
var txs = d3.selectAll('.textpoint');
444+
445+
expect(pts.size()).toEqual(ptStyle.length);
446+
expect(txs.size()).toEqual(txContent.length);
447+
448+
pts.each(function(_, i) {
449+
expect(d3.select(this).style('fill')).toEqual(ptStyle[i], 'pt ' + i);
450+
});
451+
452+
txs.each(function(_, i) {
453+
expect(d3.select(this).select('text').text()).toEqual(txContent[i], 'tx ' + i);
454+
});
455+
}
456+
457+
it('should reorder point and text nodes even when linked to ids (shuffle case)', function(done) {
458+
Plotly.plot(gd, [{
459+
x: [150, 350, 650],
460+
y: [100, 300, 600],
461+
text: ['apple', 'banana', 'clementine'],
462+
ids: ['A', 'B', 'C'],
463+
mode: 'markers+text',
464+
marker: {
465+
color: ['rgb(255, 0, 0)', 'rgb(0, 255, 0)', 'rgb(0, 0, 255)']
466+
},
467+
transforms: [{
468+
type: 'sort',
469+
enabled: false,
470+
target: [0, 1, 0]
471+
}]
472+
}])
473+
.then(function() {
474+
_assertNodes(
475+
['rgb(255, 0, 0)', 'rgb(0, 255, 0)', 'rgb(0, 0, 255)'],
476+
['apple', 'banana', 'clementine']
477+
);
478+
479+
return Plotly.restyle(gd, 'transforms[0].enabled', true);
480+
})
481+
.then(function() {
482+
_assertNodes(
483+
['rgb(255, 0, 0)', 'rgb(0, 0, 255)', 'rgb(0, 255, 0)'],
484+
['apple', 'clementine', 'banana']
485+
);
486+
487+
return Plotly.restyle(gd, 'transforms[0].enabled', false);
488+
})
489+
.then(function() {
490+
_assertNodes(
491+
['rgb(255, 0, 0)', 'rgb(0, 255, 0)', 'rgb(0, 0, 255)'],
492+
['apple', 'banana', 'clementine']
493+
);
494+
})
495+
.catch(fail)
496+
.then(done);
497+
});
498+
499+
it('should reorder point and text nodes even when linked to ids (add/remove case)', function(done) {
500+
Plotly.plot(gd, [{
501+
x: [150, 350, null, 600],
502+
y: [100, 300, null, 700],
503+
text: ['apple', 'banana', null, 'clementine'],
504+
ids: ['A', 'B', null, 'C'],
505+
mode: 'markers+text',
506+
marker: {
507+
color: ['rgb(255, 0, 0)', 'rgb(0, 255, 0)', null, 'rgb(0, 0, 255)']
508+
},
509+
transforms: [{
510+
type: 'filter',
511+
enabled: false,
512+
target: [1, 0, 0, 1],
513+
operation: '=',
514+
value: 1
515+
}]
516+
}])
517+
.then(function() {
518+
_assertNodes(
519+
['rgb(255, 0, 0)', 'rgb(0, 255, 0)', 'rgb(0, 0, 255)'],
520+
['apple', 'banana', 'clementine']
521+
);
522+
523+
return Plotly.restyle(gd, 'transforms[0].enabled', true);
524+
})
525+
.then(function() {
526+
_assertNodes(
527+
['rgb(255, 0, 0)', 'rgb(0, 0, 255)'],
528+
['apple', 'clementine']
529+
);
530+
531+
return Plotly.restyle(gd, 'transforms[0].enabled', false);
532+
})
533+
.then(function() {
534+
_assertNodes(
535+
['rgb(255, 0, 0)', 'rgb(0, 255, 0)', 'rgb(0, 0, 255)'],
536+
['apple', 'banana', 'clementine']
537+
);
538+
})
539+
.catch(fail)
540+
.then(done);
541+
});
440542
});
441543

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

0 commit comments

Comments
 (0)