Skip to content

Commit

Permalink
add double click test
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Feb 15, 2016
1 parent 8b6783f commit e8ef663
Showing 1 changed file with 17 additions and 0 deletions.
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);

This comment has been minimized.

Copy link
@etpinard

etpinard Feb 15, 2016

Author Contributor

@mdtusz easy double click simulator

}

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();
});
});
});

0 comments on commit e8ef663

Please sign in to comment.