Skip to content

Commit a4fb8cd

Browse files
committed
DRY modebar tests
1 parent 460ece0 commit a4fb8cd

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

test/jasmine/tests/modebar_test.js

+10-20
Original file line numberDiff line numberDiff line change
@@ -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, [], {})
@@ -1337,16 +1347,6 @@ describe('ModeBar', function() {
13371347
});
13381348

13391349
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-
13501350
Plotly.plot(gd, [], {modebar: { bgcolor: colors[0]}})
13511351
.then(function() {
13521352
style = window.getComputedStyle(gd._fullLayout._modeBar.element);
@@ -1364,16 +1364,6 @@ describe('ModeBar', function() {
13641364
});
13651365

13661366
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-
13771367
Plotly.plot(gd, [], {modebar: {bgcolor: colors[0]}}, {displayModeBar: true})
13781368
.then(function() {
13791369
style = window.getComputedStyle(gd._fullLayout._modeBar.element);

0 commit comments

Comments
 (0)