@@ -257,7 +257,7 @@ describe('hover info', function() {
257257 } ;
258258
259259 beforeEach ( function ( ) {
260- this . gd = createGraphDiv ( ) ;
260+ this . gd = createGraphDiv ( ) ;
261261 } ) ;
262262
263263 it ( 'should display the correct format when ticklabels true' , function ( ) {
@@ -281,4 +281,49 @@ describe('hover info', function() {
281281 expect ( hovers . select ( 'text' ) [ 0 ] [ 0 ] . textContent ) . toEqual ( '0.23' ) ;
282282 } ) ;
283283 } ) ;
284+
285+ describe ( 'textmode' , function ( ) {
286+
287+ var data = [ {
288+ x : [ 1 , 2 , 3 , 4 ] ,
289+ y : [ 2 , 3 , 4 , 5 ] ,
290+ mode : 'text' ,
291+ hoverinfo : 'text' ,
292+ text : [ 'test' , null , 42 , undefined ]
293+ } ] ,
294+ layout = {
295+ width : 600 ,
296+ height : 400
297+ } ;
298+
299+ beforeEach ( function ( done ) {
300+ Plotly . plot ( createGraphDiv ( ) , data , layout ) . then ( done ) ;
301+ } ) ;
302+
303+ it ( 'should show text labels' , function ( ) {
304+ mouseEvent ( 'mousemove' , 115 , 310 ) ;
305+ var hovers = d3 . selectAll ( 'g.hovertext' ) ;
306+ expect ( hovers . size ( ) ) . toEqual ( 1 ) ;
307+ expect ( hovers . select ( 'text' ) [ 0 ] [ 0 ] . textContent ) . toEqual ( 'test' ) ;
308+ } ) ;
309+
310+ it ( 'should show number labels' , function ( ) {
311+ mouseEvent ( 'mousemove' , 370 , 180 ) ;
312+ var hovers = d3 . selectAll ( 'g.hovertext' ) ;
313+ expect ( hovers . size ( ) ) . toEqual ( 1 ) ;
314+ expect ( hovers . select ( 'text' ) [ 0 ] [ 0 ] . textContent ) . toEqual ( '42' ) ;
315+ } ) ;
316+
317+ it ( 'should not show null text labels' , function ( ) {
318+ mouseEvent ( 'mousemove' , 236 , 246 ) ;
319+ var hovers = d3 . selectAll ( 'g.hovertext' ) ;
320+ expect ( hovers . size ( ) ) . toEqual ( 0 ) ;
321+ } ) ;
322+
323+ it ( 'should not show undefined text labels' , function ( ) {
324+ mouseEvent ( 'mousemove' , 500 , 115 ) ;
325+ var hovers = d3 . selectAll ( 'g.hovertext' ) ;
326+ expect ( hovers . size ( ) ) . toEqual ( 0 ) ;
327+ } ) ;
328+ } ) ;
284329} ) ;
0 commit comments