@@ -1290,6 +1290,16 @@ describe('ModeBar', function() {
12901290 expect ( style . fill ) . toBe ( color ) ;
12911291 }
12921292
1293+ function getStyleRule ( ) {
1294+ var uid = gd . _fullLayout . _uid ;
1295+ var ownerNode = document . getElementById ( 'plotly.js-style-modebar-' + uid ) ;
1296+ var styleSheets = document . styleSheets ;
1297+ for ( var i = 0 ; i < styleSheets . length ; i ++ ) {
1298+ var ss = styleSheets [ i ] ;
1299+ if ( ss . ownerNode === ownerNode ) return ss ;
1300+ }
1301+ }
1302+
12931303 it ( 'create an associated style element and destroy it on purge' , function ( done ) {
12941304 var styleSelector , style ;
12951305 Plotly . plot ( gd , [ ] , { } )
@@ -1313,7 +1323,7 @@ describe('ModeBar', function() {
13131323 button = selectButton ( gd . _fullLayout . _modeBar , targetBtn ) ;
13141324 checkButtonColor ( button , colors [ 0 ] ) ;
13151325 } )
1316- . then ( function ( ) { Plotly . relayout ( gd , 'modebar.color' , colors [ 1 ] ) ; } )
1326+ . then ( function ( ) { return Plotly . relayout ( gd , 'modebar.color' , colors [ 1 ] ) ; } )
13171327 . then ( function ( ) {
13181328 checkButtonColor ( button , colors [ 1 ] ) ;
13191329 } )
@@ -1336,16 +1346,35 @@ describe('ModeBar', function() {
13361346 . then ( done ) ;
13371347 } ) ;
13381348
1339- it ( 'changes background color' , function ( done ) {
1349+ it ( 'changes background color (displayModeBar: hover) ' , function ( done ) {
13401350 Plotly . plot ( gd , [ ] , { modebar : { bgcolor : colors [ 0 ] } } )
1351+ . then ( function ( ) {
1352+ style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
1353+ expect ( style . backgroundColor ) . toBe ( 'rgba(0, 0, 0, 0)' ) ;
1354+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
1355+ } )
1356+ . then ( function ( ) { return Plotly . relayout ( gd , 'modebar.bgcolor' , colors [ 1 ] ) ; } )
1357+ . then ( function ( ) {
1358+ style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
1359+ expect ( style . backgroundColor ) . toBe ( 'rgba(0, 0, 0, 0)' ) ;
1360+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
1361+ } )
1362+ . catch ( failTest )
1363+ . then ( done ) ;
1364+ } ) ;
1365+
1366+ it ( 'changes background color (displayModeBar: true)' , function ( done ) {
1367+ Plotly . plot ( gd , [ ] , { modebar : { bgcolor : colors [ 0 ] } } , { displayModeBar : true } )
13411368 . then ( function ( ) {
13421369 style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
13431370 expect ( style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
1371+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
13441372 } )
1345- . then ( function ( ) { Plotly . relayout ( gd , 'modebar.bgcolor' , colors [ 1 ] ) ; } )
1373+ . then ( function ( ) { return Plotly . relayout ( gd , 'modebar.bgcolor' , colors [ 1 ] ) ; } )
13461374 . then ( function ( ) {
13471375 style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
13481376 expect ( style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
1377+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
13491378 } )
13501379 . catch ( failTest )
13511380 . then ( done ) ;
@@ -1360,7 +1389,7 @@ describe('ModeBar', function() {
13601389 size = modeBarEl . getBoundingClientRect ( ) ;
13611390 expect ( size . width < size . height ) . toBeTruthy ( ) ;
13621391 } )
1363- . then ( function ( ) { Plotly . relayout ( gd , 'modebar.orientation' , 'h' ) ; } )
1392+ . then ( function ( ) { return Plotly . relayout ( gd , 'modebar.orientation' , 'h' ) ; } )
13641393 . catch ( failTest )
13651394 . then ( function ( ) {
13661395 size = modeBarEl . getBoundingClientRect ( ) ;
0 commit comments