@@ -1290,6 +1290,16 @@ describe('ModeBar', function() {
1290
1290
expect ( style . fill ) . toBe ( color ) ;
1291
1291
}
1292
1292
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
+
1293
1303
it ( 'create an associated style element and destroy it on purge' , function ( done ) {
1294
1304
var styleSelector , style ;
1295
1305
Plotly . plot ( gd , [ ] , { } )
@@ -1313,7 +1323,7 @@ describe('ModeBar', function() {
1313
1323
button = selectButton ( gd . _fullLayout . _modeBar , targetBtn ) ;
1314
1324
checkButtonColor ( button , colors [ 0 ] ) ;
1315
1325
} )
1316
- . then ( function ( ) { Plotly . relayout ( gd , 'modebar.color' , colors [ 1 ] ) ; } )
1326
+ . then ( function ( ) { return Plotly . relayout ( gd , 'modebar.color' , colors [ 1 ] ) ; } )
1317
1327
. then ( function ( ) {
1318
1328
checkButtonColor ( button , colors [ 1 ] ) ;
1319
1329
} )
@@ -1336,16 +1346,35 @@ describe('ModeBar', function() {
1336
1346
. then ( done ) ;
1337
1347
} ) ;
1338
1348
1339
- it ( 'changes background color' , function ( done ) {
1349
+ it ( 'changes background color (displayModeBar: hover) ' , function ( done ) {
1340
1350
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 } )
1341
1368
. then ( function ( ) {
1342
1369
style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
1343
1370
expect ( style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
1371
+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
1344
1372
} )
1345
- . then ( function ( ) { Plotly . relayout ( gd , 'modebar.bgcolor' , colors [ 1 ] ) ; } )
1373
+ . then ( function ( ) { return Plotly . relayout ( gd , 'modebar.bgcolor' , colors [ 1 ] ) ; } )
1346
1374
. then ( function ( ) {
1347
1375
style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
1348
1376
expect ( style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
1377
+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
1349
1378
} )
1350
1379
. catch ( failTest )
1351
1380
. then ( done ) ;
@@ -1360,7 +1389,7 @@ describe('ModeBar', function() {
1360
1389
size = modeBarEl . getBoundingClientRect ( ) ;
1361
1390
expect ( size . width < size . height ) . toBeTruthy ( ) ;
1362
1391
} )
1363
- . then ( function ( ) { Plotly . relayout ( gd , 'modebar.orientation' , 'h' ) ; } )
1392
+ . then ( function ( ) { return Plotly . relayout ( gd , 'modebar.orientation' , 'h' ) ; } )
1364
1393
. catch ( failTest )
1365
1394
. then ( function ( ) {
1366
1395
size = modeBarEl . getBoundingClientRect ( ) ;
0 commit comments