@@ -11,6 +11,9 @@ var createGraphDiv = require('../assets/create_graph_div');
1111var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
1212var fail = require ( '../assets/fail_test' ) ;
1313
14+ var mouseEvent = require ( '../assets/mouse_event' ) ;
15+ var assertHoverLabelContent = require ( '../assets/custom_assertions' ) . assertHoverLabelContent ;
16+
1417describe ( 'carpet supplyDefaults' , function ( ) {
1518 'use strict' ;
1619
@@ -565,3 +568,39 @@ describe('scattercarpet array attributes', function() {
565568 . then ( done ) ;
566569 } ) ;
567570} ) ;
571+
572+ describe ( 'scattercarpet hover labels' , function ( ) {
573+ var gd ;
574+
575+ afterEach ( destroyGraphDiv ) ;
576+
577+ function run ( pos , fig , content ) {
578+ gd = createGraphDiv ( ) ;
579+
580+ return Plotly . plot ( gd , fig ) . then ( function ( ) {
581+ mouseEvent ( 'mousemove' , pos [ 0 ] , pos [ 1 ] ) ;
582+ assertHoverLabelContent ( [ content , null ] ) ;
583+ } ) ;
584+ }
585+
586+ it ( 'should generate hover label (base)' , function ( done ) {
587+ var fig = Lib . extendDeep ( { } , require ( '@mocks/scattercarpet.json' ) ) ;
588+
589+ run (
590+ [ 200 , 200 ] , fig ,
591+ [ [ 'a = 0.200' , 'b = 3.500' , 'y = 2.900' ] , 'a = 0.2' ]
592+ )
593+ . then ( done ) ;
594+ } ) ;
595+
596+ it ( 'should generate hover label with \'hoverinfo\' set' , function ( done ) {
597+ var fig = Lib . extendDeep ( { } , require ( '@mocks/scattercarpet.json' ) ) ;
598+ fig . data [ 5 ] . hoverinfo = 'a+y' ;
599+
600+ run (
601+ [ 200 , 200 ] , fig ,
602+ [ [ 'a = 0.200' , 'y = 2.900' ] , null ]
603+ )
604+ . then ( done ) ;
605+ } ) ;
606+ } ) ;
0 commit comments