Skip to content

Commit 58badcc

Browse files
committed
Add test for doubleclick reset -> drag to zoom
1 parent 113e802 commit 58badcc

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

test/jasmine/tests/click_test.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ describe('Test click interactions:', function() {
3737
});
3838
}
3939

40+
function drag(fromX, fromY, toX, toY) {
41+
return new Promise(function(resolve) {
42+
mouseEvent('mousemove', fromX, fromY);
43+
mouseEvent('mousedown', fromX, fromY);
44+
mouseEvent('mousemove', toX, toY);
45+
46+
setTimeout(function() {
47+
mouseEvent('mouseup', toX, toY);
48+
resolve();
49+
}, DBLCLICKDELAY / 2);
50+
});
51+
}
52+
4053
describe('click events', function() {
4154
var futureData;
4255

@@ -97,7 +110,7 @@ describe('Test click interactions:', function() {
97110
});
98111
});
99112

100-
describe('double click interactions', function() {
113+
fdescribe('double click interactions', function() {
101114
var mockCopy;
102115

103116
var autoRangeX = [-3.011967491973726, 2.1561305597186564],
@@ -196,6 +209,27 @@ describe('Test click interactions:', function() {
196209
});
197210
});
198211

212+
it('when set to \'reset+autorange\' (the default) should autosize on 1st double click and zoom when immediately dragged', function(done) {
213+
mockCopy = setRanges(mockCopy);
214+
215+
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(function() {
216+
expect(gd.layout.xaxis.range).toBeCloseToArray(setRangeX);
217+
expect(gd.layout.yaxis.range).toBeCloseToArray(setRangeY);
218+
219+
return doubleClick(blankPos[0], blankPos[1]);
220+
}).then(function() {
221+
expect(gd.layout.xaxis.range).toBeCloseToArray(autoRangeX);
222+
expect(gd.layout.yaxis.range).toBeCloseToArray(autoRangeY);
223+
224+
return drag(100, 100, 200, 200);
225+
}).then(function() {
226+
expect(gd.layout.xaxis.range).toBeCloseToArray([-2.70624901567643, -1.9783478816352495]);
227+
expect(gd.layout.yaxis.range).toBeCloseToArray([0.5007032802920716, 1.2941670624404753]);
228+
229+
done();
230+
});
231+
});
232+
199233
it('when set to \'reset+autorange\' (the default) should follow updated auto ranges', function(done) {
200234
var updateData = {
201235
x: [[1e-4, 0, 1e3]],

0 commit comments

Comments
 (0)