Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add double click test
  • Loading branch information
etpinard committed Feb 15, 2016
commit e8ef66306b4ebaf7df709de8880371026d6bbdf9
17 changes: 17 additions & 0 deletions test/jasmine/tests/click_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var Plotly = require('@lib/index');
var Lib = require('@src/lib');
var DBLCLICKDELAY = require('@src/plots/cartesian/constants').DBLCLICKDELAY;

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

function doubleClick(cb) {
click();
setTimeout(function() {
click();
cb();
}, DBLCLICKDELAY / 2);
}

beforeEach(function(done) {
gd = createGraphDiv();

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

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

gd.on('plotly_doubleclick', function(data) {
futureData = data;
});

doubleClick(function() {
expect(futureData).toBe(null);
done();
});
});
});