@@ -537,44 +537,52 @@ describe('sankey tests', function() {
537537 mouseEvent ( 'mouseout' , pos [ 0 ] , pos [ 1 ] ) ;
538538 } ) ;
539539
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' ) ;
542542
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+ }
545548
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 ) ;
551551
552552 Plotly . plot ( gd , fig )
553- . then ( function ( ) { return _hover ( 'node' ) ; } )
553+ . then ( function ( ) { return _click ( 'node' ) ; } )
554554 . then ( function ( d ) {
555555 _assert ( d , {
556556 curveNumber : 0 ,
557557 pointNumber : 4 ,
558558 label : 'Solid'
559559 } ) ;
560560 } )
561- . then ( function ( ) { return _hover ( 'link' ) ; } )
561+ . then ( function ( ) { return _click ( 'link' ) ; } )
562562 . then ( function ( d ) {
563563 _assert ( d , {
564564 curveNumber : 0 ,
565565 pointNumber : 61 ,
566566 value : 46.477
567567 } ) ;
568568 } )
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' ) ; } )
570578 . then ( function ( d ) {
571579 _assert ( d , {
572580 curveNumber : 0 ,
573581 pointNumber : 4 ,
574582 label : 'Solid'
575583 } ) ;
576584 } )
577- . then ( function ( ) { return _click ( 'link' ) ; } )
585+ . then ( function ( ) { return _hover ( 'link' ) ; } )
578586 . then ( function ( d ) {
579587 _assert ( d , {
580588 curveNumber : 0 ,
@@ -601,6 +609,30 @@ describe('sankey tests', function() {
601609 . catch ( failTest )
602610 . then ( done ) ;
603611 } ) ;
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+ } ) ;
604636 } ) ;
605637} ) ;
606638
0 commit comments