@@ -537,44 +537,52 @@ describe('sankey tests', function() {
537
537
mouseEvent ( 'mouseout' , pos [ 0 ] , pos [ 1 ] ) ;
538
538
} ) ;
539
539
540
- it ( 'should output correct hover/click/unhover event data' , function ( done ) {
541
- var fig = Lib . extendDeep ( { } , mock ) ;
540
+ function _assert ( d , expectedPtData ) {
541
+ expect ( d . event ) . toBeDefined ( 'original event reference' ) ;
542
542
543
- function _assert ( d , expectedPtData ) {
544
- expect ( d . event ) . toBeDefined ( 'original event reference' ) ;
543
+ var ptData = d . points [ 0 ] ;
544
+ Object . keys ( expectedPtData ) . forEach ( function ( k ) {
545
+ expect ( ptData [ k ] ) . toBe ( expectedPtData [ k ] , 'point data for ' + k ) ;
546
+ } ) ;
547
+ }
545
548
546
- var ptData = d . points [ 0 ] ;
547
- Object . keys ( expectedPtData ) . forEach ( function ( k ) {
548
- expect ( ptData [ k ] ) . toBe ( expectedPtData [ k ] , 'point data for ' + k ) ;
549
- } ) ;
550
- }
549
+ it ( 'should output correct click event data' , function ( done ) {
550
+ var fig = Lib . extendDeep ( { } , mock ) ;
551
551
552
552
Plotly . plot ( gd , fig )
553
- . then ( function ( ) { return _hover ( 'node' ) ; } )
553
+ . then ( function ( ) { return _click ( 'node' ) ; } )
554
554
. then ( function ( d ) {
555
555
_assert ( d , {
556
556
curveNumber : 0 ,
557
557
pointNumber : 4 ,
558
558
label : 'Solid'
559
559
} ) ;
560
560
} )
561
- . then ( function ( ) { return _hover ( 'link' ) ; } )
561
+ . then ( function ( ) { return _click ( 'link' ) ; } )
562
562
. then ( function ( d ) {
563
563
_assert ( d , {
564
564
curveNumber : 0 ,
565
565
pointNumber : 61 ,
566
566
value : 46.477
567
567
} ) ;
568
568
} )
569
- . then ( function ( ) { return _click ( 'node' ) ; } )
569
+ . catch ( failTest )
570
+ . then ( done ) ;
571
+ } ) ;
572
+
573
+ it ( 'should output correct hover/unhover event data' , function ( done ) {
574
+ var fig = Lib . extendDeep ( { } , mock ) ;
575
+
576
+ Plotly . plot ( gd , fig )
577
+ . then ( function ( ) { return _hover ( 'node' ) ; } )
570
578
. then ( function ( d ) {
571
579
_assert ( d , {
572
580
curveNumber : 0 ,
573
581
pointNumber : 4 ,
574
582
label : 'Solid'
575
583
} ) ;
576
584
} )
577
- . then ( function ( ) { return _click ( 'link' ) ; } )
585
+ . then ( function ( ) { return _hover ( 'link' ) ; } )
578
586
. then ( function ( d ) {
579
587
_assert ( d , {
580
588
curveNumber : 0 ,
@@ -601,6 +609,30 @@ describe('sankey tests', function() {
601
609
. catch ( failTest )
602
610
. then ( done ) ;
603
611
} ) ;
612
+
613
+ it ( 'should not output hover/unhover event data when hovermoder is false' , function ( done ) {
614
+ var fig = Lib . extendDeep ( { } , mock ) ;
615
+
616
+ Plotly . plot ( gd , fig )
617
+ . then ( function ( ) { return Plotly . relayout ( gd , 'hovermode' , false ) ; } )
618
+ . then ( function ( ) { return _hover ( 'node' ) ; } )
619
+ . then ( failTest ) . catch ( function ( err ) {
620
+ expect ( err ) . toBe ( 'plotly_hover did not get called!' ) ;
621
+ } )
622
+ . then ( function ( ) { return _unhover ( 'node' ) ; } )
623
+ . then ( failTest ) . catch ( function ( err ) {
624
+ expect ( err ) . toBe ( 'plotly_unhover did not get called!' ) ;
625
+ } )
626
+ . then ( function ( ) { return _hover ( 'link' ) ; } )
627
+ . then ( failTest ) . catch ( function ( err ) {
628
+ expect ( err ) . toBe ( 'plotly_hover did not get called!' ) ;
629
+ } )
630
+ . then ( function ( ) { return _unhover ( 'link' ) ; } )
631
+ . then ( failTest ) . catch ( function ( err ) {
632
+ expect ( err ) . toBe ( 'plotly_unhover did not get called!' ) ;
633
+ } )
634
+ . then ( done ) ;
635
+ } ) ;
604
636
} ) ;
605
637
} ) ;
606
638
0 commit comments