Skip to content

Commit 6b72540

Browse files
committed
Added unit test for bug fix
1 parent c25bc9b commit 6b72540

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/jasmine/tests/legend_test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,6 +2742,38 @@ describe('legend with custom doubleClickDelay', function() {
27422742
.then(_assert('[short] after click + (1.1*t) delay + click', 2, 0))
27432743
.then(done, done.fail);
27442744
}, 3 * jasmine.DEFAULT_TIMEOUT_INTERVAL);
2745+
2746+
it('custom plotly_legenddoubleclick handler should fire even when plotly_legendclick has been cancelled', function(done) {
2747+
var tShort = 0.75 * DBLCLICKDELAY;
2748+
var dblClickCnt = 0;
2749+
var newPlot = function(fig) {
2750+
return Plotly.newPlot(gd, fig).then(function() {
2751+
gd.on('plotly_legendclick', function() { return false; });
2752+
gd.on('plotly_legenddoubleclick', function() { dblClickCnt++; });
2753+
});
2754+
};
2755+
2756+
function _assert(msg, _dblClickCnt) {
2757+
return function() {
2758+
expect(dblClickCnt).toBe(_dblClickCnt, msg + '| dblClickCnt');
2759+
dblClickCnt = 0;
2760+
};
2761+
}
2762+
2763+
newPlot({
2764+
data: [
2765+
{y: [1, 2, 1]},
2766+
{y: [2, 1, 2]}
2767+
],
2768+
layout: {},
2769+
config: {}
2770+
})
2771+
.then(click(0))
2772+
.then(delay(tShort))
2773+
.then(click(0))
2774+
.then(_assert('Double click increases count', 1))
2775+
.then(done);
2776+
}, 3 * jasmine.DEFAULT_TIMEOUT_INTERVAL);
27452777
});
27462778

27472779
describe('legend with custom legendwidth', function() {

0 commit comments

Comments
 (0)