Skip to content

Commit 1de0d19

Browse files
committed
add tests checking axis ranges after partial deletion
1 parent 8fac52d commit 1de0d19

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/jasmine/tests/plot_interact_test.js

+13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var Lib = require('@src/lib');
55

66
var createGraphDiv = require('../assets/create_graph_div');
77
var destroyGraphDiv = require('../assets/destroy_graph_div');
8+
var customMatchers = require('../assets/custom_matchers');
89

910

1011
describe('Test plot structure', function() {
@@ -97,32 +98,44 @@ describe('Test plot structure', function() {
9798
});
9899

99100
it('should restore layout axes when they get deleted', function(done) {
101+
jasmine.addMatchers(customMatchers);
102+
100103
expect(countScatterTraces()).toEqual(mock.data.length);
101104
expect(countSubplots()).toEqual(1);
102105

103106
Plotly.relayout(gd, {xaxis: null, yaxis: null}).then(function() {
104107
expect(countScatterTraces()).toEqual(1);
105108
expect(countSubplots()).toEqual(1);
109+
expect(gd.layout.xaxis.range).toBeCloseToArray([-4.79980, 74.48580], 4);
110+
expect(gd.layout.yaxis.range).toBeCloseToArray([-1.2662, 17.67023], 4);
106111

107112
return Plotly.relayout(gd, 'xaxis', null);
108113
}).then(function() {
109114
expect(countScatterTraces()).toEqual(1);
110115
expect(countSubplots()).toEqual(1);
116+
expect(gd.layout.xaxis.range).toBeCloseToArray([-4.79980, 74.48580], 4);
117+
expect(gd.layout.yaxis.range).toBeCloseToArray([-1.2662, 17.67023], 4);
111118

112119
return Plotly.relayout(gd, 'xaxis', {});
113120
}).then(function() {
114121
expect(countScatterTraces()).toEqual(1);
115122
expect(countSubplots()).toEqual(1);
123+
expect(gd.layout.xaxis.range).toBeCloseToArray([-4.79980, 74.48580], 4);
124+
expect(gd.layout.yaxis.range).toBeCloseToArray([-1.2662, 17.67023], 4);
116125

117126
return Plotly.relayout(gd, 'yaxis', null);
118127
}).then(function() {
119128
expect(countScatterTraces()).toEqual(1);
120129
expect(countSubplots()).toEqual(1);
130+
expect(gd.layout.xaxis.range).toBeCloseToArray([-4.79980, 74.48580], 4);
131+
expect(gd.layout.yaxis.range).toBeCloseToArray([-1.2662, 17.67023], 4);
121132

122133
return Plotly.relayout(gd, 'yaxis', {});
123134
}).then(function() {
124135
expect(countScatterTraces()).toEqual(1);
125136
expect(countSubplots()).toEqual(1);
137+
expect(gd.layout.xaxis.range).toBeCloseToArray([-4.79980, 74.48580], 4);
138+
expect(gd.layout.yaxis.range).toBeCloseToArray([-1.2662, 17.67023], 4);
126139

127140
done();
128141
});

0 commit comments

Comments
 (0)