@@ -371,38 +371,50 @@ describe('Test hover and click interactions', function() {
371371
372372 var modifiedMockCopy = Lib . extendDeep ( { } , mock4 ) ;
373373
374- Plotly . plot ( gd , modifiedMockCopy . data , modifiedMockCopy . layout )
375-
376- . then ( new Promise ( function ( ) {
377-
378- gd . on ( 'plotly_hover' , function ( data ) {
379- futureData = data ;
380- } ) ;
381-
382- hover ( 435 , 216 ) ;
383-
384- window . setTimeout ( function ( ) {
385-
386- expect ( futureData . points . length ) . toEqual ( 1 ) ;
387-
388- var pt = futureData . points [ 0 ] ;
374+ function _hover ( ) {
375+ hover ( 435 , 216 ) ;
389376
390- expect ( Object . keys ( pt ) ) . toEqual ( [
391- 'x' , 'y' , 'curveNumber' , 'pointNumber' , 'data' , 'fullData' , 'xaxis' , 'yaxis'
392- ] ) ;
393-
394- expect ( pt . x ) . toEqual ( 8 ) ;
395- expect ( pt . y ) . toEqual ( 18 ) ;
396- expect ( pt . curveNumber ) . toEqual ( 2 ) ;
397- expect ( pt . pointNumber ) . toEqual ( 0 ) ;
398- expect ( pt . fullData . length ) . toEqual ( 3 ) ;
399- expect ( typeof pt . data . uid ) . toEqual ( 'string' ) ;
400- expect ( pt . xaxis . domain . length ) . toEqual ( 2 ) ;
401- expect ( pt . yaxis . domain . length ) . toEqual ( 2 ) ;
377+ return new Promise ( function ( resolve ) {
378+ setTimeout ( resolve , 350 ) ;
379+ } ) ;
380+ }
402381
403- done ( ) ;
404- } , 350 ) ;
405- } ) ) ;
382+ Plotly . plot ( gd , modifiedMockCopy . data , modifiedMockCopy . layout ) . then ( function ( ) {
383+ gd . on ( 'plotly_hover' , function ( data ) {
384+ futureData = data ;
385+ } ) ;
386+ } )
387+ . then ( _hover )
388+ . then ( function ( ) {
389+ expect ( futureData . points . length ) . toEqual ( 1 ) ;
390+
391+ var pt = futureData . points [ 0 ] ;
392+
393+ expect ( Object . keys ( pt ) ) . toEqual ( [
394+ 'x' , 'y' , 'curveNumber' , 'pointNumber' , 'data' , 'fullData' , 'xaxis' , 'yaxis'
395+ ] ) ;
396+
397+ expect ( pt . x ) . toEqual ( 8 ) ;
398+ expect ( pt . y ) . toEqual ( 18 ) ;
399+ expect ( pt . curveNumber ) . toEqual ( 2 ) ;
400+ expect ( pt . pointNumber ) . toEqual ( 0 ) ;
401+ expect ( pt . fullData . length ) . toEqual ( 3 ) ;
402+ expect ( typeof pt . data . uid ) . toEqual ( 'string' ) ;
403+ expect ( pt . xaxis . domain . length ) . toEqual ( 2 ) ;
404+ expect ( pt . yaxis . domain . length ) . toEqual ( 2 ) ;
405+
406+ return Plotly . restyle ( gd , 'visible' , false , [ 1 , 2 ] ) ;
407+ } )
408+ . then ( _hover )
409+ . then ( function ( ) {
410+ var pt = futureData . points [ 0 ] ;
411+
412+ expect ( pt . x ) . toEqual ( 8 ) ;
413+ expect ( pt . y ) . toEqual ( 18 ) ;
414+ expect ( pt . curveNumber ) . toEqual ( 2 , 'matches input data index' ) ;
415+ expect ( pt . pointNumber ) . toEqual ( 0 ) ;
416+ } )
417+ . then ( done ) ;
406418 } ) ;
407419
408420 it ( 'scattergl-fancy' , function ( done ) {
0 commit comments