@@ -36,6 +36,41 @@ function touch(path, options) {
3636    return ; 
3737} 
3838
39+ describe ( 'Fx.hover:' ,  function ( )  { 
40+     var  gd ; 
41+ 
42+     beforeEach ( function ( )  {  gd  =  createGraphDiv ( ) ;  } ) ; 
43+ 
44+     afterEach ( destroyGraphDiv ) ; 
45+ 
46+     it ( 'should warn when passing subplot ids that are not part of the graph' ,  function ( done )  { 
47+         spyOn ( Lib ,  'warn' ) ; 
48+ 
49+         var  data  =  [ 
50+             { y : [ 1 ] ,  hoverinfo : 'y' } 
51+         ] ; 
52+ 
53+         var  layout  =  { 
54+             xaxis : { domain : [ 0 ,  0.5 ] } , 
55+             xaxis2 : { anchor : 'y2' ,  domain : [ 0.5 ,  1 ] } , 
56+             yaxis2 : { anchor : 'x2' } , 
57+             width : 400 , 
58+             height : 200 , 
59+             margin : { l : 0 ,  t : 0 ,  r : 0 ,  b : 0 } , 
60+             showlegend : false 
61+         } ; 
62+ 
63+         Plotly . plot ( gd ,  data ,  layout ) 
64+         . then ( function ( )  { 
65+             Fx . hover ( gd ,  { xpx : 300 ,  ypx : 100 } ,  'x2y2' ) ; 
66+             expect ( gd . _hoverdata ) . toBe ( undefined ,  'did not generate hoverdata' ) ; 
67+             expect ( Lib . warn ) . toHaveBeenCalledWith ( 'Unrecognized subplot: x2y2' ) ; 
68+         } ) 
69+         . catch ( failTest ) 
70+         . then ( done ) ; 
71+     } ) ; 
72+ } ) ; 
73+ 
3974describe ( 'hover info' ,  function ( )  { 
4075    'use strict' ; 
4176
@@ -2150,7 +2185,6 @@ describe('hover info on stacked subplots', function() {
21502185    } ) ; 
21512186} ) ; 
21522187
2153- 
21542188describe ( 'hover on many lines+bars' ,  function ( )  { 
21552189    'use strict' ; 
21562190
@@ -2607,6 +2641,56 @@ describe('hover updates', function() {
26072641        } ) 
26082642        . then ( done ) ; 
26092643    } ) ; 
2644+ 
2645+     it ( 'should not attempt to rehover over exiting subplots' ,  function ( done )  { 
2646+         spyOn ( Fx ,  'hover' ) . and . callThrough ( ) ; 
2647+ 
2648+         var  data  =  [ 
2649+             { y : [ 1 ] ,  hoverinfo : 'y' } , 
2650+             { y : [ 2 ] ,  hoverinfo : 'y' ,  xaxis : 'x2' ,  yaxis : 'y2' } 
2651+         ] ; 
2652+ 
2653+         var  data2  =  [ 
2654+             { y : [ 1 ] ,  hoverinfo : 'y' } 
2655+         ] ; 
2656+ 
2657+         var  layout  =  { 
2658+             xaxis : { domain : [ 0 ,  0.5 ] } , 
2659+             xaxis2 : { anchor : 'y2' ,  domain : [ 0.5 ,  1 ] } , 
2660+             yaxis2 : { anchor : 'x2' } , 
2661+             width : 400 , 
2662+             height : 200 , 
2663+             margin : { l : 0 ,  t : 0 ,  r : 0 ,  b : 0 } , 
2664+             showlegend : false 
2665+         } ; 
2666+ 
2667+         var  gd  =  createGraphDiv ( ) ; 
2668+         var  onPt2  =  [ 300 ,  100 ] ; 
2669+         var  offPt2  =  [ 250 ,  100 ] ; 
2670+ 
2671+         Plotly . react ( gd ,  data ,  layout ) 
2672+         . then ( function ( )  { 
2673+             assertLabelsCorrect ( onPt2 ,  [ 303 ,  100 ] ,  '2' ,  'after 1st draw [on-pt]' ) ; 
2674+             assertLabelsCorrect ( offPt2 ,  null ,  null ,  'after 1st draw [off-pt]' ) ; 
2675+             expect ( Fx . hover ) . toHaveBeenCalledTimes ( 2 ) ; 
2676+         } ) 
2677+         . then ( function ( )  { 
2678+             var  promise  =  Plotly . react ( gd ,  data2 ,  layout ) ; 
2679+             assertLabelsCorrect ( onPt2 ,  null ,  null ,  '2' ,  'before react() resolves [on-pt]' ) ; 
2680+             assertLabelsCorrect ( offPt2 ,  null ,  null ,  'before react() resolves [off-pt]' ) ; 
2681+             // N.B. no calls from Plots.rehover() as x2y2 subplot got removed! 
2682+             expect ( Fx . hover ) . toHaveBeenCalledTimes ( 2 ) ; 
2683+             return  promise ; 
2684+         } ) 
2685+         . then ( function ( )  { 
2686+             expect ( Fx . hover ) . toHaveBeenCalledTimes ( 2 ) ; 
2687+             assertLabelsCorrect ( onPt2 ,  null ,  null ,  '2' ,  'after react() resolves [on-pt]' ) ; 
2688+             assertLabelsCorrect ( offPt2 ,  null ,  null ,  'after react() resolves [off-pt]' ) ; 
2689+             expect ( Fx . hover ) . toHaveBeenCalledTimes ( 2 ) ; 
2690+         } ) 
2691+         . catch ( failTest ) 
2692+         . then ( done ) ; 
2693+     } ) ; 
26102694} ) ; 
26112695
26122696describe ( 'Test hover label custom styling:' ,  function ( )  { 
0 commit comments