@@ -23,6 +23,7 @@ var defaultColors = require('@src/components/color/attributes').defaults;
23
23
var drag = require ( '../assets/drag' ) ;
24
24
var checkOverlap = require ( '../assets/check_overlap' ) ;
25
25
var delay = require ( '../assets/delay' ) ;
26
+ var selectButton = require ( '../assets/modebar_button' ) ;
26
27
27
28
describe ( 'sankey tests' , function ( ) {
28
29
'use strict' ;
@@ -560,6 +561,52 @@ describe('sankey tests', function() {
560
561
. catch ( failTest )
561
562
. then ( done ) ;
562
563
} ) ;
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
+ } ) ;
563
610
} ) ;
564
611
565
612
describe ( 'Test hover/click interactions:' , function ( ) {
0 commit comments