Skip to content

Commit 70470f7

Browse files
committed
#30a proper grouping by interaction type
1 parent 43a7236 commit 70470f7

File tree

1 file changed

+86
-163
lines changed

1 file changed

+86
-163
lines changed

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 86 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ describe('Test gl plot interactions', function() {
228228
});
229229
});
230230

231-
describe('gl3d modebar click handlers', function() {
231+
describe('gl3d event handlers', function() {
232232
var modeBar, relayoutCallback;
233233

234234
beforeEach(function(done) {
@@ -265,151 +265,98 @@ describe('Test gl plot interactions', function() {
265265
});
266266
}
267267

268-
describe('button zoom3d', function() {
269-
it('should updates the scene dragmode and dragmode button', function() {
270-
var buttonTurntable = selectButton(modeBar, 'tableRotation'),
271-
buttonZoom3d = selectButton(modeBar, 'zoom3d');
272-
273-
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
274-
expect(buttonTurntable.isActive()).toBe(true);
275-
expect(buttonZoom3d.isActive()).toBe(false);
276-
277-
buttonZoom3d.click();
278-
assertScenes(gd.layout, 'dragmode', 'zoom');
279-
expect(gd.layout.dragmode).toBe(undefined);
280-
expect(gd._fullLayout.dragmode).toBe('zoom');
281-
expect(buttonTurntable.isActive()).toBe(false);
282-
expect(buttonZoom3d.isActive()).toBe(true);
283-
284-
buttonTurntable.click();
285-
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
286-
expect(buttonTurntable.isActive()).toBe(true);
287-
expect(buttonZoom3d.isActive()).toBe(false);
288-
});
289-
});
290-
291-
describe('button pan3d', function() {
292-
it('should updates the scene dragmode and dragmode button', function() {
293-
var buttonTurntable = selectButton(modeBar, 'tableRotation'),
294-
buttonPan3d = selectButton(modeBar, 'pan3d');
295-
296-
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
297-
expect(buttonTurntable.isActive()).toBe(true);
298-
expect(buttonPan3d.isActive()).toBe(false);
299-
300-
buttonPan3d.click();
301-
assertScenes(gd.layout, 'dragmode', 'pan');
302-
expect(gd.layout.dragmode).toBe(undefined);
303-
expect(gd._fullLayout.dragmode).toBe('zoom');
304-
expect(buttonTurntable.isActive()).toBe(false);
305-
expect(buttonPan3d.isActive()).toBe(true);
306-
307-
buttonTurntable.click();
308-
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
309-
expect(buttonTurntable.isActive()).toBe(true);
310-
expect(buttonPan3d.isActive()).toBe(false);
311-
});
312-
});
268+
describe('modebar click handlers', function() {
313269

314-
describe('button orbitRotation', function() {
315-
it('should updates the scene dragmode and dragmode button', function() {
316-
var buttonTurntable = selectButton(modeBar, 'tableRotation'),
317-
buttonOrbit = selectButton(modeBar, 'orbitRotation');
318-
319-
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
320-
expect(buttonTurntable.isActive()).toBe(true);
321-
expect(buttonOrbit.isActive()).toBe(false);
322-
323-
buttonOrbit.click();
324-
assertScenes(gd.layout, 'dragmode', 'orbit');
325-
expect(gd.layout.dragmode).toBe(undefined);
326-
expect(gd._fullLayout.dragmode).toBe('zoom');
327-
expect(buttonTurntable.isActive()).toBe(false);
328-
expect(buttonOrbit.isActive()).toBe(true);
329-
330-
buttonTurntable.click();
331-
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
332-
expect(buttonTurntable.isActive()).toBe(true);
333-
expect(buttonOrbit.isActive()).toBe(false);
334-
});
335-
});
270+
describe('button zoom3d', function() {
271+
it('should updates the scene dragmode and dragmode button', function() {
272+
var buttonTurntable = selectButton(modeBar, 'tableRotation'),
273+
buttonZoom3d = selectButton(modeBar, 'zoom3d');
336274

337-
describe('buttons resetCameraDefault3d and resetCameraLastSave3d', function() {
338-
it('should update the scene camera', function(done) {
339-
var sceneLayout = gd._fullLayout.scene,
340-
sceneLayout2 = gd._fullLayout.scene2,
341-
scene = sceneLayout._scene,
342-
scene2 = sceneLayout2._scene;
275+
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
276+
expect(buttonTurntable.isActive()).toBe(true);
277+
expect(buttonZoom3d.isActive()).toBe(false);
343278

344-
expect(sceneLayout.camera.eye)
345-
.toEqual({x: 0.1, y: 0.1, z: 1});
346-
expect(sceneLayout2.camera.eye)
347-
.toEqual({x: 2.5, y: 2.5, z: 2.5});
348-
349-
selectButton(modeBar, 'resetCameraDefault3d').click();
350-
351-
setTimeout(function() {
352-
353-
expect(relayoutCallback).toHaveBeenCalledTimes(2); // initiator: resetCameraDefault3d; 2 scenes
354-
expect(relayoutCallback).toHaveBeenCalledWith({
355-
scene: {
356-
eye: { x: 1.25, y: 1.25, z: 1.25 },
357-
center: { x: 0, y: 0, z: 0 },
358-
up: { x: 0, y: 0, z: 1 }
359-
}
360-
});
361-
expect(relayoutCallback).toHaveBeenCalledWith({
362-
scene2: {
363-
center: { x: 0, y: 0, z: 0 },
364-
eye: { x: 1.25, y: 1.25, z: 1.25 },
365-
up: { x: 0, y: 0, z: 1 }
366-
}
367-
});
368-
relayoutCallback.calls.reset();
279+
buttonZoom3d.click();
280+
assertScenes(gd.layout, 'dragmode', 'zoom');
281+
expect(gd.layout.dragmode).toBe(undefined);
282+
expect(gd._fullLayout.dragmode).toBe('zoom');
283+
expect(buttonTurntable.isActive()).toBe(false);
284+
expect(buttonZoom3d.isActive()).toBe(true);
369285

370-
expect(sceneLayout.camera.eye)
371-
.toEqual({x: 0.1, y: 0.1, z: 1}, 'does not change the layout objects');
372-
expect(scene.camera.eye)
373-
.toBeCloseToArray([1.25, 1.25, 1.25], 4);
374-
expect(sceneLayout2.camera.eye)
375-
.toEqual({x: 2.5, y: 2.5, z: 2.5}, 'does not change the layout objects');
376-
expect(scene2.camera.eye)
377-
.toBeCloseToArray([1.25, 1.25, 1.25], 4);
378-
379-
selectButton(modeBar, 'resetCameraLastSave3d').click();
380-
381-
setTimeout(function() {
382-
383-
expect(relayoutCallback).toHaveBeenCalledTimes(2); // initiator: resetCameraLastSave3d; 2 scenes
384-
expect(relayoutCallback).toHaveBeenCalledWith({
385-
scene: {
386-
center: { x: 0, y: 0, z: 0 },
387-
eye: { x: 0.1, y: 0.1, z: 1 },
388-
up: { x: 0, y: 0, z: 1 }
389-
}
390-
});
391-
expect(relayoutCallback).toHaveBeenCalledWith({
392-
scene2: {
393-
center: { x: 0, y: 0, z: 0 },
394-
eye: { x: 2.5, y: 2.5, z: 2.5 },
395-
up: { x: 0, y: 0, z: 1 }
396-
}
397-
});
398-
399-
expect(sceneLayout.camera.eye)
400-
.toEqual({x: 0.1, y: 0.1, z: 1}, 'does not change the layout objects');
401-
expect(scene.camera.eye)
402-
.toBeCloseToArray([ 0.1, 0.1, 1], 4);
403-
expect(sceneLayout2.camera.eye)
404-
.toEqual({x: 2.5, y: 2.5, z: 2.5}, 'does not change the layout objects');
405-
expect(scene2.camera.eye)
406-
.toBeCloseToArray([2.5, 2.5, 2.5], 4);
286+
buttonTurntable.click();
287+
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
288+
expect(buttonTurntable.isActive()).toBe(true);
289+
expect(buttonZoom3d.isActive()).toBe(false);
290+
});
291+
});
407292

408-
done();
293+
describe('button pan3d', function() {
294+
it('should updates the scene dragmode and dragmode button', function() {
295+
var buttonTurntable = selectButton(modeBar, 'tableRotation'),
296+
buttonPan3d = selectButton(modeBar, 'pan3d');
297+
298+
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
299+
expect(buttonTurntable.isActive()).toBe(true);
300+
expect(buttonPan3d.isActive()).toBe(false);
301+
302+
buttonPan3d.click();
303+
assertScenes(gd.layout, 'dragmode', 'pan');
304+
expect(gd.layout.dragmode).toBe(undefined);
305+
expect(gd._fullLayout.dragmode).toBe('zoom');
306+
expect(buttonTurntable.isActive()).toBe(false);
307+
expect(buttonPan3d.isActive()).toBe(true);
308+
309+
buttonTurntable.click();
310+
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
311+
expect(buttonTurntable.isActive()).toBe(true);
312+
expect(buttonPan3d.isActive()).toBe(false);
313+
});
314+
});
409315

410-
}, MODEBAR_DELAY);
316+
describe('button orbitRotation', function() {
317+
it('should updates the scene dragmode and dragmode button', function() {
318+
var buttonTurntable = selectButton(modeBar, 'tableRotation'),
319+
buttonOrbit = selectButton(modeBar, 'orbitRotation');
320+
321+
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
322+
expect(buttonTurntable.isActive()).toBe(true);
323+
expect(buttonOrbit.isActive()).toBe(false);
324+
325+
buttonOrbit.click();
326+
assertScenes(gd.layout, 'dragmode', 'orbit');
327+
expect(gd.layout.dragmode).toBe(undefined);
328+
expect(gd._fullLayout.dragmode).toBe('zoom');
329+
expect(buttonTurntable.isActive()).toBe(false);
330+
expect(buttonOrbit.isActive()).toBe(true);
331+
332+
buttonTurntable.click();
333+
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
334+
expect(buttonTurntable.isActive()).toBe(true);
335+
expect(buttonOrbit.isActive()).toBe(false);
336+
});
337+
});
411338

412-
}, MODEBAR_DELAY);
339+
describe('button hoverClosest3d', function() {
340+
it('should update the scene hovermode and spikes', function() {
341+
var buttonHover = selectButton(modeBar, 'hoverClosest3d');
342+
343+
assertScenes(gd._fullLayout, 'hovermode', 'closest');
344+
expect(buttonHover.isActive()).toBe(true);
345+
346+
buttonHover.click();
347+
assertScenes(gd._fullLayout, 'hovermode', false);
348+
assertScenes(gd._fullLayout, 'xaxis.showspikes', false);
349+
assertScenes(gd._fullLayout, 'yaxis.showspikes', false);
350+
assertScenes(gd._fullLayout, 'zaxis.showspikes', false);
351+
expect(buttonHover.isActive()).toBe(false);
352+
353+
buttonHover.click();
354+
assertScenes(gd._fullLayout, 'hovermode', 'closest');
355+
assertScenes(gd._fullLayout, 'xaxis.showspikes', true);
356+
assertScenes(gd._fullLayout, 'yaxis.showspikes', true);
357+
assertScenes(gd._fullLayout, 'zaxis.showspikes', true);
358+
expect(buttonHover.isActive()).toBe(true);
359+
});
413360
});
414361
});
415362

@@ -459,30 +406,6 @@ describe('Test gl plot interactions', function() {
459406
}, MODEBAR_DELAY);
460407
});
461408
});
462-
463-
describe('button hoverClosest3d', function() {
464-
it('should update the scene hovermode and spikes', function() {
465-
var buttonHover = selectButton(modeBar, 'hoverClosest3d');
466-
467-
assertScenes(gd._fullLayout, 'hovermode', 'closest');
468-
expect(buttonHover.isActive()).toBe(true);
469-
470-
buttonHover.click();
471-
assertScenes(gd._fullLayout, 'hovermode', false);
472-
assertScenes(gd._fullLayout, 'xaxis.showspikes', false);
473-
assertScenes(gd._fullLayout, 'yaxis.showspikes', false);
474-
assertScenes(gd._fullLayout, 'zaxis.showspikes', false);
475-
expect(buttonHover.isActive()).toBe(false);
476-
477-
buttonHover.click();
478-
assertScenes(gd._fullLayout, 'hovermode', 'closest');
479-
assertScenes(gd._fullLayout, 'xaxis.showspikes', true);
480-
assertScenes(gd._fullLayout, 'yaxis.showspikes', true);
481-
assertScenes(gd._fullLayout, 'zaxis.showspikes', true);
482-
expect(buttonHover.isActive()).toBe(true);
483-
});
484-
});
485-
486409
});
487410

488411
describe('Plots.cleanPlot', function() {

0 commit comments

Comments
 (0)