@@ -269,6 +269,70 @@ describe('hover info', function() {
269269 } ) ;
270270 } ) ;
271271
272+ describe ( '\'closest\' hover info (superimposed case)' , function ( ) {
273+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
274+
275+ // superimposed traces
276+ mockCopy . data . push ( Lib . extendDeep ( { } , mockCopy . data [ 0 ] ) ) ;
277+ mockCopy . layout . hovermode = 'closest' ;
278+
279+ var gd ;
280+
281+ beforeEach ( function ( done ) {
282+ gd = createGraphDiv ( ) ;
283+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
284+ } ) ;
285+
286+ it ( 'render hover labels of the above trace' , function ( ) {
287+ Fx . hover ( 'graph' , evt , 'xy' ) ;
288+
289+ expect ( gd . _hoverdata . length ) . toEqual ( 1 ) ;
290+
291+ var hoverTrace = gd . _hoverdata [ 0 ] ;
292+
293+ expect ( hoverTrace . fullData . index ) . toEqual ( 1 ) ;
294+ expect ( hoverTrace . curveNumber ) . toEqual ( 1 ) ;
295+ expect ( hoverTrace . pointNumber ) . toEqual ( 16 ) ;
296+ expect ( hoverTrace . x ) . toEqual ( 0.33 ) ;
297+ expect ( hoverTrace . y ) . toEqual ( 1.25 ) ;
298+
299+ expect ( d3 . selectAll ( 'g.axistext' ) . size ( ) ) . toEqual ( 0 ) ;
300+ expect ( d3 . selectAll ( 'g.hovertext' ) . size ( ) ) . toEqual ( 1 ) ;
301+
302+ var expectations = [ 'PV learning ...' , '(0.33, 1.25)' ] ;
303+ d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'text' ) . each ( function ( _ , i ) {
304+ expect ( d3 . select ( this ) . html ( ) ) . toEqual ( expectations [ i ] ) ;
305+ } ) ;
306+ } ) ;
307+
308+ it ( 'render only non-hoverinfo \'none\' hover labels' , function ( done ) {
309+
310+ Plotly . restyle ( gd , 'hoverinfo' , [ 'none' , 'name' ] ) . then ( function ( ) {
311+ Fx . hover ( 'graph' , evt , 'xy' ) ;
312+
313+ expect ( gd . _hoverdata . length ) . toEqual ( 1 ) ;
314+
315+ var hoverTrace = gd . _hoverdata [ 0 ] ;
316+
317+ expect ( hoverTrace . fullData . index ) . toEqual ( 1 ) ;
318+ expect ( hoverTrace . curveNumber ) . toEqual ( 1 ) ;
319+ expect ( hoverTrace . pointNumber ) . toEqual ( 16 ) ;
320+ expect ( hoverTrace . x ) . toEqual ( 0.33 ) ;
321+ expect ( hoverTrace . y ) . toEqual ( 1.25 ) ;
322+
323+ expect ( d3 . selectAll ( 'g.axistext' ) . size ( ) ) . toEqual ( 0 ) ;
324+ expect ( d3 . selectAll ( 'g.hovertext' ) . size ( ) ) . toEqual ( 1 ) ;
325+
326+ var text = d3 . selectAll ( 'g.hovertext' ) . select ( 'text' ) ;
327+ expect ( text . size ( ) ) . toEqual ( 1 ) ;
328+ expect ( text . html ( ) ) . toEqual ( 'PV learning ...' ) ;
329+
330+ done ( ) ;
331+ } ) ;
332+
333+ } ) ;
334+ } ) ;
335+
272336 describe ( 'hoverformat' , function ( ) {
273337
274338 var data = [ {
0 commit comments