@@ -305,6 +305,7 @@ describe('@gl Test streamtube hover', function() {
305305 mouseEvent ( 'mouseover' , 193 , 177 ) ;
306306 return delay ( 20 ) ( ) ;
307307 }
308+
308309 Plotly . plot ( gd , fig )
309310 . then ( delay ( 20 ) )
310311 . then ( _hover )
@@ -322,4 +323,57 @@ describe('@gl Test streamtube hover', function() {
322323 . catch ( failTest )
323324 . then ( done ) ;
324325 } ) ;
326+
327+ it ( 'should emit correct event data' , function ( done ) {
328+ var fig = Lib . extendDeep ( { } , require ( '@mocks/gl3d_streamtube-simple.json' ) ) ;
329+ fig . data [ 0 ] . showscale = false ;
330+ fig . layout . margin = { l : 0 , t : 0 , r : 0 , b : 0 } ;
331+ fig . layout . width = 400 ;
332+ fig . layout . height = 400 ;
333+
334+ var TOL = 2 ;
335+ var ptData ;
336+
337+ function _hover ( ) {
338+ mouseEvent ( 'mouseover' , 188 , 199 ) ;
339+ return delay ( 20 ) ( ) ;
340+ }
341+
342+ Plotly . plot ( gd , fig )
343+ . then ( delay ( 20 ) )
344+ . then ( function ( ) {
345+ gd . on ( 'plotly_hover' , function ( d ) { ptData = d . points [ 0 ] ; } ) ;
346+ } )
347+ . then ( _hover )
348+ . then ( function ( ) {
349+ if ( ptData ) {
350+ expect ( Object . keys ( ptData ) . length ) . toBe ( 12 , 'key cnt' ) ;
351+
352+ expect ( ptData . tubex ) . toBeCloseTo ( 2.25 , TOL , 'tubex' ) ;
353+ expect ( ptData . tubey ) . toBeCloseTo ( 0.59 , TOL , 'tubey' ) ;
354+ expect ( ptData . tubez ) . toBeCloseTo ( 1.09 , TOL , 'tubez' ) ;
355+
356+ expect ( ptData . tubeu ) . toBeCloseTo ( 1.85 , TOL , 'tubeu' ) ;
357+ expect ( ptData . tubev ) . toBeCloseTo ( 0.73 , TOL , 'tubev' ) ;
358+ expect ( ptData . tubew ) . toBeCloseTo ( 0.17 , TOL , 'tubew' ) ;
359+
360+ expect ( ptData . norm ) . toBeCloseTo ( 2.06 , TOL , 'norm' ) ;
361+ expect ( ptData . divergence ) . toBeCloseTo ( 0.47 , TOL , 'divergence' ) ;
362+
363+ expect ( ptData . curveNumber ) . toBe ( 0 , 'curve number' ) ;
364+ expect ( ptData . pointNumber ) . toBe ( undefined , 'point number' ) ;
365+
366+ expect ( ptData . x ) . toBe ( undefined , 'x' ) ;
367+ expect ( ptData . y ) . toBe ( undefined , 'y' ) ;
368+ expect ( ptData . z ) . toBe ( undefined , 'z' ) ;
369+
370+ expect ( ptData . data ) . not . toBe ( undefined , 'trace data' ) ;
371+ expect ( ptData . fullData ) . not . toBe ( undefined , 'full trace data' ) ;
372+ } else {
373+ fail ( 'did not trigger plotly_hover' ) ;
374+ }
375+ } )
376+ . catch ( failTest )
377+ . then ( done ) ;
378+ } ) ;
325379} ) ;
0 commit comments