Skip to content

Commit f8a4073

Browse files
committed
sankey: test to 🔒 down modebar button that resets view
1 parent 109f77e commit f8a4073

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test/jasmine/tests/sankey_test.js

+47
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var defaultColors = require('@src/components/color/attributes').defaults;
2323
var drag = require('../assets/drag');
2424
var checkOverlap = require('../assets/check_overlap');
2525
var delay = require('../assets/delay');
26+
var selectButton = require('../assets/modebar_button');
2627

2728
describe('sankey tests', function() {
2829
'use strict';
@@ -560,6 +561,52 @@ describe('sankey tests', function() {
560561
.catch(failTest)
561562
.then(done);
562563
});
564+
565+
it('resets each subplot to its initial view (ie. x, y groups) via modebar button', function(done) {
566+
var mockCopy = Lib.extendDeep({}, require('@mocks/sankey_subplots_circular'));
567+
568+
// Set initial view
569+
mockCopy.data[0].node.x = [0.25];
570+
mockCopy.data[0].node.y = [0.25];
571+
572+
mockCopy.data[0].node.groups = [];
573+
mockCopy.data[1].node.groups = [[2, 3]];
574+
575+
Plotly.plot(gd, mockCopy)
576+
.then(function() {
577+
expect(gd._fullData[0].node.groups).toEqual([]);
578+
expect(gd._fullData[1].node.groups).toEqual([[2, 3]]);
579+
580+
// Change groups
581+
return Plotly.restyle(gd, {
582+
'node.groups': [[[1, 2]], [[]]],
583+
'node.x': [[0.1]],
584+
'node.y': [[0.1]]
585+
});
586+
})
587+
.then(function() {
588+
// Check current state
589+
expect(gd._fullData[0].node.x).toEqual([0.1]);
590+
expect(gd._fullData[0].node.y).toEqual([0.1]);
591+
592+
expect(gd._fullData[0].node.groups).toEqual([[1, 2]]);
593+
expect(gd._fullData[1].node.groups).toEqual([[]]);
594+
595+
// Click reset
596+
var resetButton = selectButton(gd._fullLayout._modeBar, 'resetViewSankey');
597+
resetButton.click();
598+
})
599+
.then(function() {
600+
// Check we are back to initial view
601+
expect(gd._fullData[0].node.x).toEqual([0.25]);
602+
expect(gd._fullData[0].node.y).toEqual([0.25]);
603+
604+
expect(gd._fullData[0].node.groups).toEqual([]);
605+
expect(gd._fullData[1].node.groups).toEqual([[2, 3]]);
606+
})
607+
.catch(failTest)
608+
.then(done);
609+
});
563610
});
564611

565612
describe('Test hover/click interactions:', function() {

0 commit comments

Comments
 (0)