@@ -2369,3 +2369,52 @@ describe('hover distance', function() {
23692369 } ) ;
23702370 } ) ;
23712371} ) ;
2372+
2373+ describe ( 'hovermode defaults to' , function ( ) {
2374+ var gd ;
2375+
2376+ beforeEach ( function ( ) {
2377+ gd = createGraphDiv ( ) ;
2378+ } ) ;
2379+
2380+ afterEach ( destroyGraphDiv ) ;
2381+
2382+ it ( '\'closest\' for cartesian plots if clickmode includes \'select\'' , function ( done ) {
2383+ Plotly . plot ( gd , [ { x : [ 1 , 2 , 3 ] , y : [ 4 , 5 , 6 ] } ] , { clickmode : 'event+select' } )
2384+ . then ( function ( ) {
2385+ expect ( gd . _fullLayout . hovermode ) . toBe ( 'closest' ) ;
2386+ } )
2387+ . catch ( failTest )
2388+ . then ( done ) ;
2389+ } ) ;
2390+
2391+ it ( '\'x\' for horizontal cartesian plots if clickmode lacks \'select\'' , function ( done ) {
2392+ Plotly . plot ( gd , [ { x : [ 1 , 2 , 3 ] , y : [ 4 , 5 , 6 ] , type : 'bar' , orientation : 'h' } ] , { clickmode : 'event' } )
2393+ . then ( function ( ) {
2394+ expect ( gd . _fullLayout . hovermode ) . toBe ( 'y' ) ;
2395+ } )
2396+ . catch ( failTest )
2397+ . then ( done ) ;
2398+ } ) ;
2399+
2400+ it ( '\'y\' for vertical cartesian plots if clickmode lacks \'select\'' , function ( done ) {
2401+ Plotly . plot ( gd , [ { x : [ 1 , 2 , 3 ] , y : [ 4 , 5 , 6 ] , type : 'bar' , orientation : 'v' } ] , { clickmode : 'event' } )
2402+ . then ( function ( ) {
2403+ expect ( gd . _fullLayout . hovermode ) . toBe ( 'x' ) ;
2404+ } )
2405+ . catch ( failTest )
2406+ . then ( done ) ;
2407+ } ) ;
2408+
2409+ it ( '\'closest\' for a non-cartesian plot' , function ( done ) {
2410+ var mock = require ( '@mocks/polar_scatter.json' ) ;
2411+ expect ( mock . layout . hovermode ) . toBeUndefined ( ) ;
2412+
2413+ Plotly . plot ( gd , mock . data , mock . layout )
2414+ . then ( function ( ) {
2415+ expect ( gd . _fullLayout . hovermode ) . toBe ( 'closest' ) ;
2416+ } )
2417+ . catch ( failTest )
2418+ . then ( done ) ;
2419+ } ) ;
2420+ } ) ;
0 commit comments