Skip to content

Commit 8190738

Browse files
committed
improve itemclick / itemdoubleclick tests
1 parent 88e566a commit 8190738

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

Diff for: test/jasmine/tests/legend_test.js

+20-18
Original file line numberDiff line numberDiff line change
@@ -1672,56 +1672,58 @@ describe('legend interaction', function() {
16721672

16731673
function run() {
16741674
return Promise.resolve()
1675-
.then(click(0, 1)).then(_assert(['legendonly', true]))
1676-
.then(click(0, 1)).then(_assert([true, true]))
1677-
.then(click(0, 2)).then(_assert([true, 'legendonly']))
1678-
.then(click(0, 2)).then(_assert([true, true]))
1675+
.then(click(0, 1)).then(_assert(['legendonly', true, true]))
1676+
.then(click(0, 1)).then(_assert([true, true, true]))
1677+
.then(click(0, 2)).then(_assert([true, 'legendonly', 'legendonly']))
1678+
.then(click(0, 2)).then(_assert([true, true, true]))
16791679
.then(function() {
16801680
return Plotly.relayout(gd, {
16811681
'legend.itemclick': false,
16821682
'legend.itemdoubleclick': false
16831683
});
16841684
})
1685-
.then(click(0, 1)).then(_assert([true, true]))
1686-
.then(click(0, 2)).then(_assert([true, true]))
1685+
.then(click(0, 1)).then(_assert([true, true, true]))
1686+
.then(click(0, 2)).then(_assert([true, true, true]))
16871687
.then(function() {
16881688
return Plotly.relayout(gd, {
16891689
'legend.itemclick': 'focus',
16901690
'legend.itemdoubleclick': 'toggle'
16911691
});
16921692
})
1693-
.then(click(0, 1)).then(_assert([true, 'legendonly']))
1694-
.then(click(0, 1)).then(_assert([true, true]))
1695-
.then(click(0, 2)).then(_assert(['legendonly', true]))
1696-
.then(click(0, 2)).then(_assert([true, true]));
1693+
.then(click(0, 1)).then(_assert([true, 'legendonly', 'legendonly']))
1694+
.then(click(0, 1)).then(_assert([true, true, true]))
1695+
.then(click(0, 2)).then(_assert(['legendonly', true, true]))
1696+
.then(click(0, 2)).then(_assert([true, true, true]));
16971697
}
16981698

16991699
it('- regular trace case', function(done) {
17001700
_assert = assertVisible;
17011701

17021702
Plotly.plot(gd, [
17031703
{ y: [1, 2, 1] },
1704-
{ y: [2, 1, 2] }
1704+
{ y: [2, 1, 2] },
1705+
{ y: [3, 5, 0] }
17051706
])
17061707
.then(run)
17071708
.catch(failTest)
17081709
.then(done);
17091710
});
17101711

17111712
it('- pie case', function(done) {
1712-
_assert = function(exp) {
1713+
_assert = function(_exp) {
17131714
return function() {
1714-
var actual = [];
1715-
if(exp[0] === 'legendonly') actual.push('B');
1716-
if(exp[1] === 'legendonly') actual.push('A');
1717-
expect(actual).toEqual(gd._fullLayout.hiddenlabels || []);
1715+
var exp = [];
1716+
if(_exp[0] === 'legendonly') exp.push('C');
1717+
if(_exp[1] === 'legendonly') exp.push('B');
1718+
if(_exp[2] === 'legendonly') exp.push('A');
1719+
expect(gd._fullLayout.hiddenlabels || []).toEqual(exp);
17181720
};
17191721
};
17201722

17211723
Plotly.plot(gd, [{
17221724
type: 'pie',
1723-
labels: ['A', 'B'],
1724-
values: [1, 2]
1725+
labels: ['A', 'B', 'C'],
1726+
values: [1, 2, 3]
17251727
}])
17261728
.then(run)
17271729
.catch(failTest)

0 commit comments

Comments
 (0)