Skip to content

Commit 096674c

Browse files
committed
match lowercase and improve test
1 parent 3daa2f3 commit 096674c

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

src/components/modebar/manage.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ function getButtonGroups(gd) {
7575

7676
function match(name, B) {
7777
if(typeof B === 'string') {
78-
if(B === name) return true;
78+
if(B.toLowerCase() === name.toLowerCase()) return true;
7979
} else {
80-
if(B.name === name || B._cat === name) return true;
80+
var v0 = B.name;
81+
var v1 = (B._cat || B.name);
82+
83+
if(v0 === name || v1 === name.toLowerCase()) return true;
8184
}
8285
return false;
8386
}

test/jasmine/tests/modebar_test.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -1727,24 +1727,26 @@ describe('ModeBar', function() {
17271727
.then(done, done.fail);
17281728
});
17291729

1730-
it('add button if removed by layout and added by config', function(done) {
1731-
function countButtons() {
1732-
var modeBarEl = gd._fullLayout._modeBar.element;
1733-
return d3Select(modeBarEl).selectAll('a.modebar-btn').size();
1734-
}
1735-
1736-
var initial = 10;
1737-
Plotly.newPlot(gd, [{y: [1, 2]}], {
1738-
modebar: {
1739-
remove: 'zoom'
1730+
['zoom', 'zoomin', 'zoomOut'].forEach(function(t) {
1731+
it('add ' + t + ' button if removed by layout and added by config', function(done) {
1732+
function countButtons() {
1733+
var modeBarEl = gd._fullLayout._modeBar.element;
1734+
return d3Select(modeBarEl).selectAll('a.modebar-btn').size();
17401735
}
1741-
}, {
1742-
modeBarButtonsToAdd: ['zoom']
1743-
})
1744-
.then(function() {
1745-
expect(countButtons()).toBe(initial);
1746-
})
1747-
.then(done, done.fail);
1736+
1737+
var initial = 10;
1738+
Plotly.newPlot(gd, [{y: [1, 2]}], {
1739+
modebar: {
1740+
remove: t
1741+
}
1742+
}, {
1743+
modeBarButtonsToAdd: [t]
1744+
})
1745+
.then(function() {
1746+
expect(countButtons()).toBe(initial);
1747+
})
1748+
.then(done, done.fail);
1749+
});
17481750
});
17491751

17501752
it('remove button if added by layout and removed by config', function(done) {

0 commit comments

Comments
 (0)