Skip to content

Commit e02a3f6

Browse files
committed
#30a adding tests for the 3d callback and DIV layout camera data update
1 parent e8aa9cb commit e02a3f6

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,58 @@ describe('Test gl plot interactions', function() {
211211

212212
});
213213

214+
describe('gl3d plots', function() {
215+
216+
var mock = require('@mocks/gl3d_scatter3d-connectgaps.json'),
217+
modeBar, relayoutCallback;
218+
219+
beforeEach(function(done) {
220+
gd = createGraphDiv();
221+
222+
Plotly.plot(gd, mock.data, mock.layout).then(function() {
223+
224+
modeBar = gd._fullLayout._modeBar;
225+
relayoutCallback = jasmine.createSpy('relayoutCallback');
226+
227+
gd.on('plotly_relayout', relayoutCallback);
228+
229+
delay(done);
230+
});
231+
});
232+
233+
it('should respond to drag interactions', function(done) {
234+
235+
// Expected shape of projection-related data
236+
var cameraStructure = {
237+
up: {x: jasmine.any(Number), y: jasmine.any(Number), z: jasmine.any(Number)},
238+
center: {x: jasmine.any(Number), y: jasmine.any(Number), z: jasmine.any(Number)},
239+
eye: {x: jasmine.any(Number), y: jasmine.any(Number), z: jasmine.any(Number)}
240+
};
241+
242+
setTimeout(function() {
243+
244+
// One 'drag': simulating fairly thoroughly as the mouseup event is also needed here
245+
mouseEvent('mousemove', 400, 200);
246+
mouseEvent('mousedown', 400, 200);
247+
mouseEvent('mousemove', 320, 320, {buttons: 1});
248+
mouseEvent('mouseup', 320, 320);
249+
250+
// Check event emission count
251+
expect(relayoutCallback).toHaveBeenCalledTimes(1);
252+
253+
// Check structure of event callback value contents
254+
expect(relayoutCallback).toHaveBeenCalledWith(jasmine.objectContaining({scene: cameraStructure}));
255+
256+
// Check camera contents on the DIV layout
257+
var divCamera = gd.layout.scene.camera;
258+
expect(divCamera).toEqual(cameraStructure);
259+
260+
delay(done);
261+
262+
}, MODEBAR_DELAY);
263+
});
264+
});
265+
214266
describe('gl2d plots', function() {
215267
var mock = require('@mocks/gl2d_10.json'),
216268
modeBar, relayoutCallback;

0 commit comments

Comments
 (0)