@@ -1336,16 +1336,55 @@ describe('ModeBar', function() {
1336
1336
. then ( done ) ;
1337
1337
} ) ;
1338
1338
1339
- it ( 'changes background color' , function ( done ) {
1339
+ it ( 'changes background color (displayModeBar: hover)' , function ( done ) {
1340
+ function getStyleRule ( ) {
1341
+ var uid = gd . _fullLayout . _uid ;
1342
+ var ownerNode = document . getElementById ( 'plotly.js-style-modebar-' + uid ) ;
1343
+ var styleSheets = document . styleSheets ;
1344
+ for ( var i = 0 ; i < styleSheets . length ; i ++ ) {
1345
+ var ss = styleSheets [ i ] ;
1346
+ if ( ss . ownerNode === ownerNode ) return ss ;
1347
+ }
1348
+ }
1349
+
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 ( ) { 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
+ function getStyleRule ( ) {
1368
+ var uid = gd . _fullLayout . _uid ;
1369
+ var ownerNode = document . getElementById ( 'plotly.js-style-modebar-' + uid ) ;
1370
+ var styleSheets = document . styleSheets ;
1371
+ for ( var i = 0 ; i < styleSheets . length ; i ++ ) {
1372
+ var ss = styleSheets [ i ] ;
1373
+ if ( ss . ownerNode === ownerNode ) return ss ;
1374
+ }
1375
+ }
1376
+
1377
+ Plotly . plot ( gd , [ ] , { modebar : { bgcolor : colors [ 0 ] } } , { displayModeBar : true } )
1341
1378
. then ( function ( ) {
1342
1379
style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
1343
1380
expect ( style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
1381
+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
1344
1382
} )
1345
1383
. then ( function ( ) { Plotly . relayout ( gd , 'modebar.bgcolor' , colors [ 1 ] ) ; } )
1346
1384
. then ( function ( ) {
1347
1385
style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
1348
1386
expect ( style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
1387
+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
1349
1388
} )
1350
1389
. catch ( failTest )
1351
1390
. then ( done ) ;
0 commit comments