Skip to content

Commit b76710d

Browse files
committed
modified condition tests
1 parent 56a570e commit b76710d

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

src/traces/surface/defaults.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2828

2929
var z = coerce('z');
3030
if(!z || !z.length ||
31-
(x ? (x.length < 2) : false) ||
32-
(y ? (y.length < 2) : false)
31+
(x ? (x.length < 1) : false) ||
32+
(y ? (y.length < 1) : false)
3333
) {
3434
traceOut.visible = false;
3535
return;
3636
}
3737

38-
3938
traceOut._xlength = (Array.isArray(x) && Lib.isArrayOrTypedArray(x[0])) ? z.length : z[0].length;
4039
traceOut._ylength = z.length;
4140

test/jasmine/tests/surface_test.js

+35-10
Original file line numberDiff line numberDiff line change
@@ -185,29 +185,40 @@ describe('Test surface', function() {
185185

186186
});
187187

188-
189188
describe('Test dimension and expected visibility tests', function() {
190189
var gd;
191190

192191
beforeEach(function() {
193192
gd = createGraphDiv();
194193
});
195194

196-
197195
afterEach(function() {
198196
Plotly.purge(gd);
199197
destroyGraphDiv();
200198
});
201199

202-
203200
function assertVisibility(exp, msg) {
204201
expect(gd._fullData[0]).not.toBe(undefined, 'no visibility!');
205202
expect(gd._fullData[0].visible).toBe(exp, msg);
206203
}
207204

208-
fit('@gl surface should be invisible when the z array is empty', function(done) {
205+
it('@gl surface should be invisible when the z array is empty', function(done) {
206+
Plotly.plot(gd, [{
207+
'type': 'surface',
208+
'z': []
209+
}])
210+
.then(function() {
211+
assertVisibility(false, 'not to be visible');
212+
})
213+
.catch(failTest)
214+
.then(done);
215+
});
216+
217+
it('@gl surface should be invisible when the x array is defined but is empty', function(done) {
209218
Plotly.plot(gd, [{
210219
'type': 'surface',
220+
'x': [],
221+
'y': [0, 1],
211222
'z': []
212223
}])
213224
.then(function() {
@@ -217,35 +228,49 @@ describe('Test surface', function() {
217228
.then(done);
218229
});
219230

220-
fit('@gl surface should be invisible when the x array is defined but has less than two rows', function(done) {
231+
it('@gl surface should be invisible when the y array is defined but is empty', function(done) {
232+
Plotly.plot(gd, [{
233+
'type': 'surface',
234+
'x': [0, 1],
235+
'y': [],
236+
'z': []
237+
}])
238+
.then(function() {
239+
assertVisibility(false, 'not to be visible');
240+
})
241+
.catch(failTest)
242+
.then(done);
243+
});
244+
245+
it('@gl surface should be invisible when the x array is defined and has at least one item', function(done) {
221246
Plotly.plot(gd, [{
222247
'type': 'surface',
223248
'x': [0],
224249
'y': [0, 1],
225250
'z': [[1], [2]]
226251
}])
227252
.then(function() {
228-
assertVisibility(false, 'not to be visible');
253+
assertVisibility(true, 'to be visible');
229254
})
230255
.catch(failTest)
231256
.then(done);
232257
});
233258

234-
fit('@gl surface should be invisible when the y array is defined but has less than two colums', function(done) {
259+
it('@gl surface should be invisible when the y array is defined and has at least one item', function(done) {
235260
Plotly.plot(gd, [{
236261
'type': 'surface',
237262
'x': [0, 1],
238263
'y': [0],
239264
'z': [[1, 2]]
240265
}])
241266
.then(function() {
242-
assertVisibility(false, 'not to be visible');
267+
assertVisibility(true, 'to be visible');
243268
})
244269
.catch(failTest)
245270
.then(done);
246271
});
247272

248-
fit('@gl surface should be visible when the x and y are not provided; but z array is provided', function(done) {
273+
it('@gl surface should be visible when the x and y are not provided; but z array is provided', function(done) {
249274
Plotly.plot(gd, [{
250275
'type': 'surface',
251276
'z': [[1, 2], [3, 4]]
@@ -257,7 +282,7 @@ describe('Test surface', function() {
257282
.then(done);
258283
});
259284

260-
fit('@gl surface should be invisible when the x and y are provided; but z array is not provided', function(done) {
285+
it('@gl surface should be invisible when the x and y are provided; but z array is not provided', function(done) {
261286
Plotly.plot(gd, [{
262287
'type': 'surface',
263288
'x': [0, 1],

0 commit comments

Comments
 (0)