Skip to content

Commit 4a3e00a

Browse files
committed
added jasmine tests
1 parent 2d7adee commit 4a3e00a

File tree

2 files changed

+92
-2
lines changed

2 files changed

+92
-2
lines changed

test/jasmine/tests/gl3d_plot_interact_test.js

-2
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,11 @@ describe('Test gl3d plots', function() {
670670
.then(done);
671671
});
672672

673-
674673
it('@gl should avoid passing blank texts to webgl', function(done) {
675674
function assertIsFilled(msg) {
676675
var fullLayout = gd._fullLayout;
677676
expect(fullLayout.scene._scene.glplot.objects[0].glyphBuffer.length).not.toBe(0, msg);
678677
}
679-
680678
Plotly.plot(gd, [{
681679
type: 'scatter3d',
682680
mode: 'text',

test/jasmine/tests/surface_test.js

+92
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
var Surface = require('@src/traces/surface');
2+
var Plotly = require('@lib/index');
3+
var failTest = require('../assets/fail_test');
4+
var createGraphDiv = require('../assets/create_graph_div');
5+
var destroyGraphDiv = require('../assets/destroy_graph_div');
26

37
var Lib = require('@src/lib');
48

@@ -178,5 +182,93 @@ describe('Test surface', function() {
178182
expect(traceOut.ycalendar).toBe('ethiopian');
179183
expect(traceOut.zcalendar).toBe('mayan');
180184
});
185+
186+
});
187+
188+
189+
describe('Test dimension and expected visibility tests', function() {
190+
var gd;
191+
192+
beforeEach(function() {
193+
gd = createGraphDiv();
194+
});
195+
196+
197+
afterEach(function() {
198+
Plotly.purge(gd);
199+
destroyGraphDiv();
200+
});
201+
202+
203+
function assertVisibility(exp, msg) {
204+
expect(gd._fullData[0]).not.toBe(undefined, 'no visibility!');
205+
expect(gd._fullData[0].visible).toBe(exp, msg);
206+
}
207+
208+
fit('@gl surface should be invisible when the z array is empty', function(done) {
209+
Plotly.plot(gd, [{
210+
'type': 'surface',
211+
'z': []
212+
}])
213+
.then(function() {
214+
assertVisibility(false, 'not to be visible');
215+
})
216+
.catch(failTest)
217+
.then(done);
218+
});
219+
220+
fit('@gl surface should be invisible when the x array is defined but has less than two rows', function(done) {
221+
Plotly.plot(gd, [{
222+
'type': 'surface',
223+
'x': [0],
224+
'y': [0, 1],
225+
'z': [[1], [2]]
226+
}])
227+
.then(function() {
228+
assertVisibility(false, 'not to be visible');
229+
})
230+
.catch(failTest)
231+
.then(done);
232+
});
233+
234+
fit('@gl surface should be invisible when the y array is defined but has less than two colums', function(done) {
235+
Plotly.plot(gd, [{
236+
'type': 'surface',
237+
'x': [0, 1],
238+
'y': [0],
239+
'z': [[1, 2]]
240+
}])
241+
.then(function() {
242+
assertVisibility(false, 'not to be visible');
243+
})
244+
.catch(failTest)
245+
.then(done);
246+
});
247+
248+
fit('@gl surface should be visible when the x and y are not provided; but z array is provided', function(done) {
249+
Plotly.plot(gd, [{
250+
'type': 'surface',
251+
'z': [[1, 2], [3, 4]]
252+
}])
253+
.then(function() {
254+
assertVisibility(true, 'to be visible');
255+
})
256+
.catch(failTest)
257+
.then(done);
258+
});
259+
260+
fit('@gl surface should be invisible when the x and y are provided; but z array is not provided', function(done) {
261+
Plotly.plot(gd, [{
262+
'type': 'surface',
263+
'x': [0, 1],
264+
'y': [0, 1]
265+
}])
266+
.then(function() {
267+
assertVisibility(false, 'to be invisible');
268+
})
269+
.catch(failTest)
270+
.then(done);
271+
});
272+
181273
});
182274
});

0 commit comments

Comments
 (0)