@@ -185,7 +185,7 @@ describe('ModeBar', function() {
185
185
[ 'toImage' , 'sendDataToCloud' ] ,
186
186
[ 'zoom2d' , 'pan2d' ] ,
187
187
[ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
188
- [ 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
188
+ [ 'toggleSpikelines' , ' hoverClosestCartesian', 'hoverCompareCartesian' ]
189
189
] ) ;
190
190
191
191
var gd = getMockGraphInfo ( ) ;
@@ -203,7 +203,7 @@ describe('ModeBar', function() {
203
203
[ 'toImage' , 'sendDataToCloud' ] ,
204
204
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
205
205
[ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
206
- [ 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
206
+ [ 'toggleSpikelines' , ' hoverClosestCartesian', 'hoverCompareCartesian' ]
207
207
] ) ;
208
208
209
209
var gd = getMockGraphInfo ( ) ;
@@ -225,7 +225,7 @@ describe('ModeBar', function() {
225
225
it ( 'creates mode bar (cartesian fixed-axes version)' , function ( ) {
226
226
var buttons = getButtons ( [
227
227
[ 'toImage' , 'sendDataToCloud' ] ,
228
- [ 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
228
+ [ 'toggleSpikelines' , ' hoverClosestCartesian', 'hoverCompareCartesian' ]
229
229
] ) ;
230
230
231
231
var gd = getMockGraphInfo ( ) ;
@@ -412,7 +412,7 @@ describe('ModeBar', function() {
412
412
var buttons = getButtons ( [
413
413
[ 'toImage' , 'sendDataToCloud' ] ,
414
414
[ 'zoom2d' , 'pan2d' ] ,
415
- [ 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
415
+ [ 'toggleSpikelines' , ' hoverClosestCartesian', 'hoverCompareCartesian' ]
416
416
] ) ;
417
417
418
418
var gd = getMockGraphInfo ( ) ;
@@ -544,7 +544,7 @@ describe('ModeBar', function() {
544
544
545
545
var modeBar = gd . _fullLayout . _modeBar ;
546
546
expect ( countGroups ( modeBar ) ) . toEqual ( 6 ) ;
547
- expect ( countButtons ( modeBar ) ) . toEqual ( 10 ) ;
547
+ expect ( countButtons ( modeBar ) ) . toEqual ( 11 ) ;
548
548
} ) ;
549
549
550
550
it ( 'sets up buttons with modeBarButtonsToAdd and modeBarButtonToRemove (2)' , function ( ) {
@@ -564,7 +564,7 @@ describe('ModeBar', function() {
564
564
565
565
var modeBar = gd . _fullLayout . _modeBar ;
566
566
expect ( countGroups ( modeBar ) ) . toEqual ( 7 ) ;
567
- expect ( countButtons ( modeBar ) ) . toEqual ( 12 ) ;
567
+ expect ( countButtons ( modeBar ) ) . toEqual ( 13 ) ;
568
568
} ) ;
569
569
570
570
it ( 'sets up buttons with fully custom modeBarButtons' , function ( ) {
@@ -612,7 +612,7 @@ describe('ModeBar', function() {
612
612
} ) ;
613
613
614
614
describe ( 'modebar on clicks' , function ( ) {
615
- var gd , modeBar ;
615
+ var gd , modeBar , buttonClosest , buttonCompare , buttonToggle , hovermodeButtons ;
616
616
617
617
beforeAll ( function ( ) {
618
618
jasmine . addMatchers ( customMatchers ) ;
@@ -685,6 +685,10 @@ describe('ModeBar', function() {
685
685
gd = createGraphDiv ( ) ;
686
686
Plotly . plot ( gd , mockData , mockLayout ) . then ( function ( ) {
687
687
modeBar = gd . _fullLayout . _modeBar ;
688
+ buttonToggle = selectButton ( modeBar , 'toggleSpikelines' ) ;
689
+ buttonCompare = selectButton ( modeBar , 'hoverCompareCartesian' ) ;
690
+ buttonClosest = selectButton ( modeBar , 'hoverClosestCartesian' ) ;
691
+ hovermodeButtons = [ buttonCompare , buttonClosest ] ;
688
692
done ( ) ;
689
693
} ) ;
690
694
} ) ;
@@ -758,21 +762,53 @@ describe('ModeBar', function() {
758
762
} ) ;
759
763
760
764
describe ( 'buttons hoverCompareCartesian and hoverClosestCartesian ' , function ( ) {
761
- it ( 'should update layout hovermode' , function ( ) {
762
- var buttonCompare = selectButton ( modeBar , 'hoverCompareCartesian' ) ,
763
- buttonClosest = selectButton ( modeBar , 'hoverClosestCartesian' ) ,
764
- buttons = [ buttonCompare , buttonClosest ] ;
765
765
766
+ it ( 'should update layout hovermode' , function ( ) {
766
767
expect ( gd . _fullLayout . hovermode ) . toBe ( 'x' ) ;
767
- assertActive ( buttons , buttonCompare ) ;
768
+ assertActive ( hovermodeButtons , buttonCompare ) ;
768
769
769
770
buttonClosest . click ( ) ;
770
771
expect ( gd . _fullLayout . hovermode ) . toBe ( 'closest' ) ;
771
- assertActive ( buttons , buttonClosest ) ;
772
+ assertActive ( hovermodeButtons , buttonClosest ) ;
772
773
773
774
buttonCompare . click ( ) ;
774
775
expect ( gd . _fullLayout . hovermode ) . toBe ( 'x' ) ;
775
- assertActive ( buttons , buttonCompare ) ;
776
+ assertActive ( hovermodeButtons , buttonCompare ) ;
777
+ } ) ;
778
+ } ) ;
779
+
780
+ describe ( 'button toggleSpikelines' , function ( ) {
781
+ it ( 'should update layout hovermode' , function ( ) {
782
+ expect ( gd . _fullLayout . hovermode ) . toBe ( 'x' ) ;
783
+ assertActive ( hovermodeButtons , buttonCompare ) ;
784
+
785
+ buttonToggle . click ( ) ;
786
+ expect ( gd . _fullLayout . hovermode ) . toBe ( 'closest' ) ;
787
+ assertActive ( hovermodeButtons , buttonClosest ) ;
788
+ } ) ;
789
+ it ( 'should makes spikelines visible' , function ( ) {
790
+ buttonToggle . click ( ) ;
791
+ expect ( gd . _fullLayout . _cartesianSpikesEnabled ) . toBe ( 'on' ) ;
792
+
793
+ buttonToggle . click ( ) ;
794
+ expect ( gd . _fullLayout . _cartesianSpikesEnabled ) . toBe ( 'off' ) ;
795
+ } ) ;
796
+ it ( 'should become disabled when hovermode is switched off closest' , function ( ) {
797
+ buttonToggle . click ( ) ;
798
+ expect ( gd . _fullLayout . _cartesianSpikesEnabled ) . toBe ( 'on' ) ;
799
+
800
+ buttonCompare . click ( ) ;
801
+ expect ( gd . _fullLayout . _cartesianSpikesEnabled ) . toBe ( 'off' ) ;
802
+ } ) ;
803
+ it ( 'should be re-enabled when hovermode is set to closest if it was previously on' , function ( ) {
804
+ buttonToggle . click ( ) ;
805
+ expect ( gd . _fullLayout . _cartesianSpikesEnabled ) . toBe ( 'on' ) ;
806
+
807
+ buttonCompare . click ( ) ;
808
+ expect ( gd . _fullLayout . _cartesianSpikesEnabled ) . toBe ( 'off' ) ;
809
+
810
+ buttonClosest . click ( ) ;
811
+ expect ( gd . _fullLayout . _cartesianSpikesEnabled ) . toBe ( 'on' ) ;
776
812
} ) ;
777
813
} ) ;
778
814
} ) ;
0 commit comments