Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80f9926

Browse files
committed
test: add a few more gl2d interaction tests
1 parent 5734107 commit 80f9926

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

test/jasmine/tests/gl2d_scatterplot_contour_test.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ var Plotly = require('@lib/index');
44
var Lib = require('@src/lib');
55
var d3 = require('d3');
66

7-
// contourgl is not part of the dist plotly.js bundle initially
7+
// heatmapgl & contourgl is not part of the dist plotly.js bundle initially
88
Plotly.register(
9+
require('@lib/heatmapgl'),
910
require('@lib/contourgl')
1011
);
1112

@@ -208,4 +209,45 @@ describe('contourgl plots', function() {
208209
mock.data[0].line = {smoothing: 0};
209210
makePlot(gd, mock, done);
210211
});
212+
213+
it('should update properly', function(done) {
214+
var mock = plotDataElliptical(0);
215+
var scene2d;
216+
217+
Plotly.plot(gd, mock.data, mock.layout).then(function() {
218+
scene2d = gd._fullLayout._plots.xy._scene2d;
219+
220+
expect(scene2d.traces[mock.data[0].uid].type).toEqual('contourgl');
221+
expect(scene2d.xaxis._min).toEqual([{ val: -1, pad: 0}]);
222+
expect(scene2d.xaxis._max).toEqual([{ val: 1, pad: 0}]);
223+
224+
return Plotly.relayout(gd, 'xaxis.range', [0, -10]);
225+
}).then(function() {
226+
expect(scene2d.xaxis._min).toEqual([]);
227+
expect(scene2d.xaxis._max).toEqual([]);
228+
229+
return Plotly.relayout(gd, 'xaxis.autorange', true);
230+
}).then(function() {
231+
expect(scene2d.xaxis._min).toEqual([{ val: -1, pad: 0}]);
232+
expect(scene2d.xaxis._max).toEqual([{ val: 1, pad: 0}]);
233+
234+
return Plotly.restyle(gd, 'type', 'heatmapgl');
235+
}).then(function() {
236+
expect(scene2d.traces[mock.data[0].uid].type).toEqual('heatmapgl');
237+
expect(scene2d.xaxis._min).toEqual([{ val: -1, pad: 0}]);
238+
expect(scene2d.xaxis._max).toEqual([{ val: 1, pad: 0}]);
239+
240+
return Plotly.relayout(gd, 'xaxis.range', [0, -10]);
241+
}).then(function() {
242+
expect(scene2d.xaxis._min).toEqual([]);
243+
expect(scene2d.xaxis._max).toEqual([]);
244+
245+
return Plotly.relayout(gd, 'xaxis.autorange', true);
246+
}).then(function() {
247+
expect(scene2d.xaxis._min).toEqual([{ val: -1, pad: 0}]);
248+
expect(scene2d.xaxis._max).toEqual([{ val: 1, pad: 0}]);
249+
250+
done();
251+
});
252+
});
211253
});

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ describe('Test gl plot interactions', function() {
248248
var newX = [-0.23224043715846995, 4.811895754518705];
249249
var newY = [-1.2962655110623016, 4.768255474123081];
250250

251+
expect(gd.layout.xaxis.autorange).toBe(true);
252+
expect(gd.layout.yaxis.autorange).toBe(true);
251253
expect(gd.layout.xaxis.range).toBeCloseToArray(originalX, precision);
252254
expect(gd.layout.yaxis.range).toBeCloseToArray(originalY, precision);
253255

@@ -270,6 +272,9 @@ describe('Test gl plot interactions', function() {
270272

271273
mouseEvent('mousemove', 220, 200, {buttons: 1});
272274

275+
expect(gd.layout.xaxis.autorange).toBe(false);
276+
expect(gd.layout.yaxis.autorange).toBe(false);
277+
273278
expect(gd.layout.xaxis.range).toBeCloseToArray(newX, precision);
274279
expect(gd.layout.yaxis.range).toBeCloseToArray(originalY, precision);
275280

0 commit comments

Comments
 (0)