Skip to content

Commit e8ef663

Browse files
committed
add double click test
1 parent 8b6783f commit e8ef663

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/jasmine/tests/click_test.js

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var Plotly = require('@lib/index');
22
var Lib = require('@src/lib');
3+
var DBLCLICKDELAY = require('@src/plots/cartesian/constants').DBLCLICKDELAY;
34

45
var createGraphDiv = require('../assets/create_graph_div');
56
var destroyGraphDiv = require('../assets/destroy_graph_div');
@@ -22,6 +23,14 @@ describe('click event', function() {
2223
mouseEvent('mouseup', clientX, clientY);
2324
}
2425

26+
function doubleClick(cb) {
27+
click();
28+
setTimeout(function() {
29+
click();
30+
cb();
31+
}, DBLCLICKDELAY / 2);
32+
}
33+
2534
beforeEach(function(done) {
2635
gd = createGraphDiv();
2736

@@ -51,8 +60,16 @@ describe('click event', function() {
5160
expect(pt.y).toEqual(2.125);
5261
});
5362

63+
it('should trigger double click if two clicks are \'close\' together', function(done) {
64+
var futureData;
5465

66+
gd.on('plotly_doubleclick', function(data) {
67+
futureData = data;
68+
});
5569

70+
doubleClick(function() {
71+
expect(futureData).toBe(null);
72+
done();
5673
});
5774
});
5875
});

0 commit comments

Comments
 (0)