Skip to content

Commit 5180356

Browse files
committed
#30a test case for mouse drag on gl2d plots
1 parent 70470f7 commit 5180356

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,18 @@ describe('Test gl plot interactions', function() {
212212
});
213213

214214
describe('gl2d plots', function() {
215-
var mock = require('@mocks/gl2d_10.json');
215+
var mock = require('@mocks/gl2d_10.json'),
216+
relayoutCallback;
216217

217218
beforeEach(function(done) {
218219
gd = createGraphDiv();
219220

220221
Plotly.plot(gd, mock.data, mock.layout).then(function() {
222+
223+
relayoutCallback = jasmine.createSpy('relayoutCallback');
224+
225+
gd.on('plotly_relayout', relayoutCallback);
226+
221227
delay(done);
222228
});
223229
});
@@ -226,6 +232,24 @@ describe('Test gl plot interactions', function() {
226232
var nodes = d3.selectAll('canvas');
227233
expect(nodes[0].length).toEqual(1);
228234
});
235+
236+
it('should respond to drag interactions', function(done) {
237+
238+
var sceneTarget = gd.querySelector('.plot-container .gl-container canvas');
239+
240+
// Drag scene
241+
sceneTarget.dispatchEvent(new MouseEvent('mousedown', {x: 0, y: 0}));
242+
sceneTarget.dispatchEvent(new MouseEvent('mousemove', { x: 100, y: 100}));
243+
sceneTarget.dispatchEvent(new MouseEvent('mouseup', { x: 100, y: 100}));
244+
245+
setTimeout(function() {
246+
247+
expect(relayoutCallback).toHaveBeenCalledTimes(1);
248+
249+
done();
250+
251+
}, MODEBAR_DELAY);
252+
});
229253
});
230254

231255
describe('gl3d event handlers', function() {

0 commit comments

Comments
 (0)