@@ -9,6 +9,7 @@ var Sankey = require('@src/traces/sankey');
99
1010var createGraphDiv = require ( '../assets/create_graph_div' ) ;
1111var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
12+ var mouseEvent = require ( '../assets/mouse_event' ) ;
1213
1314describe ( 'sankey tests' , function ( ) {
1415
@@ -269,7 +270,7 @@ describe('sankey tests', function() {
269270 . then ( function ( ) {
270271 expect ( gd . data . length ) . toEqual ( 1 ) ;
271272 expect ( d3 . selectAll ( '.sankey' ) . size ( ) ) . toEqual ( 1 ) ;
272- return Plotly . plot ( gd , mockCopy2 ) ;
273+ return Plotly . addTraces ( gd , mockCopy2 . data [ 0 ] ) ;
273274 } )
274275 . then ( function ( ) {
275276 expect ( gd . data . length ) . toEqual ( 2 ) ;
@@ -310,5 +311,32 @@ describe('sankey tests', function() {
310311 done ( ) ;
311312 } ) ;
312313 } ) ;
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+ } ) ;
313341 } ) ;
314342} ) ;
0 commit comments