Skip to content

Commit 6400baa

Browse files
committed
add tests for recalc restyle switch for zmin / zmax
- note the different behavior between heatmap-like and contour-like traces.
1 parent 52d3724 commit 6400baa

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

test/jasmine/tests/plot_api_test.js

+66
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,72 @@ describe('Test plot api', function() {
363363
expect(PlotlyInternal.plot.calls.count()).toEqual(2);
364364
});
365365

366+
it('should clear calcdata when restyling \'zmin\' and \'zmax\' on contour traces', function() {
367+
var contour = {
368+
data: [{
369+
type: 'contour',
370+
z: [[1, 2, 3], [1, 2, 1]]
371+
}]
372+
};
373+
374+
var histogram2dcontour = {
375+
data: [{
376+
type: 'histogram2dcontour',
377+
x: [1, 1, 2, 2, 2, 3],
378+
y: [0, 0, 0, 0, 1, 3]
379+
}]
380+
};
381+
382+
var mocks = [contour, histogram2dcontour];
383+
384+
mocks.forEach(function(gd) {
385+
mockDefaultsAndCalc(gd);
386+
PlotlyInternal.plot.calls.reset();
387+
Plotly.restyle(gd, 'zmin', 0);
388+
expect(gd.calcdata).toBeUndefined();
389+
expect(PlotlyInternal.plot).toHaveBeenCalled();
390+
391+
mockDefaultsAndCalc(gd);
392+
PlotlyInternal.plot.calls.reset();
393+
Plotly.restyle(gd, 'zmax', 10);
394+
expect(gd.calcdata).toBeUndefined();
395+
expect(PlotlyInternal.plot).toHaveBeenCalled();
396+
});
397+
});
398+
399+
it('should not clear calcdata when restyling \'zmin\' and \'zmax\' on heatmap traces', function() {
400+
var heatmap = {
401+
data: [{
402+
type: 'heatmap',
403+
z: [[1, 2, 3], [1, 2, 1]]
404+
}]
405+
};
406+
407+
var histogram2d = {
408+
data: [{
409+
type: 'histogram2d',
410+
x: [1, 1, 2, 2, 2, 3],
411+
y: [0, 0, 0, 0, 1, 3]
412+
}]
413+
};
414+
415+
var mocks = [heatmap, histogram2d];
416+
417+
mocks.forEach(function(gd) {
418+
mockDefaultsAndCalc(gd);
419+
PlotlyInternal.plot.calls.reset();
420+
Plotly.restyle(gd, 'zmin', 0);
421+
expect(gd.calcdata).toBeDefined();
422+
expect(PlotlyInternal.plot).toHaveBeenCalled();
423+
424+
mockDefaultsAndCalc(gd);
425+
PlotlyInternal.plot.calls.reset();
426+
Plotly.restyle(gd, 'zmax', 10);
427+
expect(gd.calcdata).toBeDefined();
428+
expect(PlotlyInternal.plot).toHaveBeenCalled();
429+
});
430+
});
431+
366432
it('ignores undefined values', function() {
367433
var gd = {
368434
data: [{x: [1, 2, 3], y: [1, 2, 3], type: 'scatter'}],

0 commit comments

Comments
 (0)