@@ -9,6 +9,7 @@ var Sankey = require('@src/traces/sankey');
9
9
10
10
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
11
11
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
12
+ var mouseEvent = require ( '../assets/mouse_event' ) ;
12
13
13
14
describe ( 'sankey tests' , function ( ) {
14
15
@@ -269,7 +270,7 @@ describe('sankey tests', function() {
269
270
. then ( function ( ) {
270
271
expect ( gd . data . length ) . toEqual ( 1 ) ;
271
272
expect ( d3 . selectAll ( '.sankey' ) . size ( ) ) . toEqual ( 1 ) ;
272
- return Plotly . plot ( gd , mockCopy2 ) ;
273
+ return Plotly . addTraces ( gd , mockCopy2 . data [ 0 ] ) ;
273
274
} )
274
275
. then ( function ( ) {
275
276
expect ( gd . data . length ) . toEqual ( 2 ) ;
@@ -310,5 +311,32 @@ describe('sankey tests', function() {
310
311
done ( ) ;
311
312
} ) ;
312
313
} ) ;
314
+
315
+ it ( 'Plotly.plot shows and removes tooltip on node, link' , function ( done ) {
316
+
317
+ var gd = createGraphDiv ( ) ;
318
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
319
+
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
+ } ) ;
340
+ } ) ;
313
341
} ) ;
314
342
} ) ;
0 commit comments