@@ -260,6 +260,12 @@ describe('sankey tests', function() {
260260
261261 afterEach ( destroyGraphDiv ) ;
262262
263+ function wait ( ) {
264+ return new Promise ( function ( resolve ) {
265+ setTimeout ( resolve , 60 ) ;
266+ } ) ;
267+ }
268+
263269 it ( 'Plotly.deleteTraces with two traces removes the deleted plot' , function ( done ) {
264270
265271 var gd = createGraphDiv ( ) ;
@@ -313,30 +319,23 @@ describe('sankey tests', function() {
313319 } ) ;
314320
315321 it ( 'Plotly.plot shows and removes tooltip on node, link' , function ( done ) {
316-
317322 var gd = createGraphDiv ( ) ;
318323 var mockCopy = Lib . extendDeep ( { } , mock ) ;
319324
320- Plotly . plot ( gd , mockCopy )
321- . then ( function ( ) {
322-
323- mouseEvent ( 'mousemove' , 400 , 300 ) ;
324- mouseEvent ( 'mouseover' , 400 , 300 ) ;
325-
326- window . setTimeout ( function ( ) {
327- expect ( d3 . select ( '.hoverlayer>.hovertext>text' ) . node ( ) . innerHTML )
328- . toEqual ( '447TWh' , 'tooltip present' ) ;
329-
330- mouseEvent ( 'mousemove' , 450 , 300 ) ;
331- mouseEvent ( 'mouseover' , 450 , 300 ) ;
332-
333- window . setTimeout ( function ( ) {
334- expect ( d3 . select ( '.hoverlayer>.hovertext>text' ) . node ( ) . innerHTML )
335- . toEqual ( '46TWh' , 'tooltip jumped to link' ) ;
336- done ( ) ;
337- } , 60 ) ;
338- } , 60 ) ;
339- } ) ;
325+ Plotly . plot ( gd , mockCopy ) . then ( function ( ) {
326+ mouseEvent ( 'mousemove' , 400 , 300 ) ;
327+ mouseEvent ( 'mouseover' , 400 , 300 ) ;
328+ } )
329+ . then ( wait )
330+ . then ( function ( ) {
331+ expect ( d3 . select ( '.hoverlayer>.hovertext>text' ) . node ( ) . innerHTML )
332+ . toEqual ( '447TWh' , 'tooltip present' ) ;
333+ } )
334+ . then ( function ( ) {
335+ mouseEvent ( 'mousemove' , 450 , 300 ) ;
336+ mouseEvent ( 'mouseover' , 450 , 300 ) ;
337+ } )
338+ . then ( done ) ;
340339 } ) ;
341340 } ) ;
342341} ) ;
0 commit comments