@@ -420,25 +420,54 @@ describe('Test geo interactions', function() {
420
420
} ) ;
421
421
422
422
describe ( 'scattergeo hover labels' , function ( ) {
423
- beforeEach ( function ( ) {
424
- mouseEventScatterGeo ( 'mousemove' ) ;
425
- } ) ;
426
-
427
423
it ( 'should show one hover text group' , function ( ) {
424
+ mouseEventScatterGeo ( 'mousemove' ) ;
428
425
expect ( d3 . selectAll ( 'g.hovertext' ) . size ( ) ) . toEqual ( 1 ) ;
429
426
} ) ;
430
427
431
428
it ( 'should show longitude and latitude values' , function ( ) {
432
- var node = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'tspan' ) [ 0 ] [ 0 ] ;
429
+ mouseEventScatterGeo ( 'mousemove' ) ;
433
430
431
+ var node = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'tspan' ) [ 0 ] [ 0 ] ;
434
432
expect ( node . innerHTML ) . toEqual ( '(0°, 0°)' ) ;
435
433
} ) ;
436
434
437
435
it ( 'should show the trace name' , function ( ) {
438
- var node = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'text' ) [ 0 ] [ 0 ] ;
436
+ mouseEventScatterGeo ( 'mousemove' ) ;
439
437
438
+ var node = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'text' ) [ 0 ] [ 0 ] ;
440
439
expect ( node . innerHTML ) . toEqual ( 'trace 0' ) ;
441
440
} ) ;
441
+
442
+ it ( 'should show *text* (case 1)' , function ( done ) {
443
+ Plotly . restyle ( gd , 'text' , [ [ 'A' , 'B' ] ] ) . then ( function ( ) {
444
+ mouseEventScatterGeo ( 'mousemove' ) ;
445
+
446
+ var node = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'tspan' ) [ 0 ] [ 1 ] ;
447
+ expect ( node . innerHTML ) . toEqual ( 'A' ) ;
448
+ } )
449
+ . then ( done ) ;
450
+ } ) ;
451
+
452
+ it ( 'should show *text* (case 2)' , function ( done ) {
453
+ Plotly . restyle ( gd , 'text' , [ [ null , 'B' ] ] ) . then ( function ( ) {
454
+ mouseEventScatterGeo ( 'mousemove' ) ;
455
+
456
+ var node = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'tspan' ) [ 0 ] [ 1 ] ;
457
+ expect ( node ) . toBeUndefined ( ) ;
458
+ } )
459
+ . then ( done ) ;
460
+ } ) ;
461
+
462
+ it ( 'should show *text* (case 3)' , function ( done ) {
463
+ Plotly . restyle ( gd , 'text' , [ [ '' , 'B' ] ] ) . then ( function ( ) {
464
+ mouseEventScatterGeo ( 'mousemove' ) ;
465
+
466
+ var node = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'tspan' ) [ 0 ] [ 1 ] ;
467
+ expect ( node ) . toBeUndefined ( ) ;
468
+ } )
469
+ . then ( done ) ;
470
+ } ) ;
442
471
} ) ;
443
472
444
473
describe ( 'scattergeo hover events' , function ( ) {
0 commit comments