Skip to content

Commit 324e69b

Browse files
committed
fixed jasmine default sync calls
1 parent 28fbc25 commit 324e69b

File tree

2 files changed

+103
-112
lines changed

2 files changed

+103
-112
lines changed

Diff for: src/traces/isosurface/attributes.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ function makeSliceAttr(axLetter) {
3636
'Specifies the location(s) of slices on the axis [0, n].',
3737
'When not locations specified slices would be created for',
3838
'all (0, n) i.e. except start and end caps. Please note that',
39-
'if a location do not match the point on the (x|y|z) axis,',
39+
'if a location do not match the point on the', axLetter, 'axis,',
4040
'the slicing plane would simply be located on the closest',
41-
'point on the axis in question (no interpolation on the axis).'
41+
'point on the axis (does not interpolate on the axis).'
4242
].join(' ')
4343
},
4444
fill: {
@@ -64,7 +64,7 @@ function makeCapAttr(axLetter) {
6464
role: 'info',
6565
dflt: true,
6666
description: [
67-
'Sets the fill ratio of the `slices`. The default fill value of the',
67+
'Sets the fill ratio of the `slices`. The default fill value of the', axLetter,
6868
'`slices` is 1 meaning that they are entirely shaded. On the other hand',
6969
'Applying a `fill` ratio less than one would allow the creation of',
7070
'openings parallel to the edges.'
@@ -169,7 +169,14 @@ var attrs = module.exports = overrideAll(extendFlat({
169169
values: ['all', 'checker1', 'checker2', 'A', 'B', 'C', 'AB', 'AC', 'BC', 'ABC'],
170170
dflt: 'all',
171171
role: 'style',
172-
description: 'Sets the fill ratio of the iso-surface.'
172+
description: [
173+
'Sets the surface pattern of the iso-surface 3-D sections. The default pattern of',
174+
'the surface is `all` meaning that the rest of surface elements would be shaded.',
175+
'The checker options (either 1 or 2) could be used to draw half of the squares',
176+
'on the surface. Using various combinations of capital `A`, `B`, and `C` may also',
177+
'be used to reduce the number of triangles on the iso-surfaces and creating other',
178+
'patterns of interest.'
179+
].join(' ')
173180
}
174181
},
175182

Diff for: test/jasmine/tests/isosurface_test.js

+92-108
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var Plotly = require('@lib');
22
// var Lib = require('@src/lib');
33

4+
var supplyAllDefaults = require('../assets/supply_defaults');
45
var createGraphDiv = require('../assets/create_graph_div');
56
var destroyGraphDiv = require('../assets/destroy_graph_div');
67
var failTest = require('../assets/fail_test');
@@ -49,74 +50,111 @@ describe('Test isosurface', function() {
4950

5051
var gd;
5152

52-
beforeEach(function() {
53-
gd = createGraphDiv();
54-
});
55-
56-
afterEach(function() {
57-
Plotly.purge(gd);
58-
destroyGraphDiv();
59-
});
53+
describe('defaults', function() {
6054

61-
function assertVisibility(exp, msg) {
62-
expect(gd._fullData[0]).not.toBe(undefined, 'no visibility!');
63-
expect(gd._fullData[0].visible).toBe(exp, msg);
64-
}
55+
function assertVisibility(exp, msg) {
56+
expect(gd._fullData[0]).not.toBe(undefined, 'no visibility!');
57+
expect(gd._fullData[0].visible).toBe(exp, msg);
58+
}
6559

66-
function assertPositions(exp, msg) {
67-
expect(gd._fullLayout.scene._scene.glplot.objects[0].positions.length).toBe(exp, msg);
68-
}
60+
it('@gl isosurface should not set `visible: false` for traces with x,y,z,value arrays', function() {
61+
gd = createIsosurfaceFig();
6962

70-
function assertCells(exp, msg) {
71-
expect(gd._fullLayout.scene._scene.glplot.objects[0].cells.length).toBe(exp, msg);
72-
}
63+
supplyAllDefaults(gd);
64+
assertVisibility(true, 'to be visible');
65+
});
7366

67+
it('@gl isosurface should set `visible: false` for traces missing x,y,z,value arrays', function() {
68+
var keysToChange = ['x', 'y', 'z', 'value'];
7469

75-
describe('defaults', function() {
70+
keysToChange.forEach(function(k) {
71+
gd = createIsosurfaceFig();
72+
delete gd.data[0][k];
7673

77-
it('@gl isosurface should not set `visible: false` for traces with x,y,z,value arrays', function(done) {
78-
Plotly.plot(gd, createIsosurfaceFig())
79-
.then(function() {
80-
assertVisibility(true, 'to be visible');
81-
})
82-
.catch(failTest)
83-
.then(done);
74+
supplyAllDefaults(gd);
75+
assertVisibility(false, 'to be invisible after changing key: ' + keysToChange[k]);
76+
});
8477
});
8578

86-
it('@gl isosurface should set `visible: false` for traces missing x,y,z,value arrays', function(done) {
79+
it('@gl isosurface should set `visible: false` for traces with empty x,y,z,value arrays', function() {
8780
var keysToChange = ['x', 'y', 'z', 'value'];
8881

8982
keysToChange.forEach(function(k) {
90-
var fig = createIsosurfaceFig();
91-
delete fig.data[0][k];
83+
gd = createIsosurfaceFig();
84+
gd.data[0][k] = [];
9285

93-
Plotly.plot(gd, fig)
94-
.then(function() {
95-
assertVisibility(false, 'to be invisible after changing key: ' + keysToChange[k]);
96-
})
97-
98-
.catch(failTest)
99-
.then(done);
86+
supplyAllDefaults(gd);
87+
assertVisibility(false, 'to be invisible after changing key: ' + keysToChange[k]);
10088
});
10189
});
10290

103-
it('@gl isosurface should set `visible: false` for traces with empty x,y,z,value arrays', function(done) {
91+
it('@gl isosurface should be invisible when the vertex arrays are not arrays', function() {
10492
var keysToChange = ['x', 'y', 'z', 'value'];
93+
var casesToCheck = [0, 1, true, false, NaN, Infinity, -Infinity, null, undefined, [], {}, '', 'text'];
10594

10695
keysToChange.forEach(function(k) {
107-
var fig = createIsosurfaceFig();
108-
fig.data[0][k] = [];
109-
110-
Plotly.plot(gd, fig)
111-
.then(function() {
112-
assertVisibility(false, 'to be invisible after changing key: ' + keysToChange[k]);
113-
})
96+
for(var q = 0; q < casesToCheck.length; q++) {
97+
gd = createIsosurfaceFig();
98+
gd.data[0][k] = casesToCheck[q];
11499

115-
.catch(failTest)
116-
.then(done);
100+
supplyAllDefaults(gd);
101+
assertVisibility(false, 'to be invisible after changing key: ' + keysToChange[k]) + ' to: ' + casesToCheck[q];
102+
}
117103
});
118104
});
119105

106+
it('@gl isosurface should not set `visible: false` when isomin > isomax', function() {
107+
gd = createIsosurfaceFig();
108+
gd.data[0].isomin = 0.9;
109+
gd.data[0].isomax = 0.1;
110+
111+
supplyAllDefaults(gd);
112+
assertVisibility(true, 'to be visible');
113+
});
114+
115+
it('@gl isosurface should set `isomin: null` and `isomax: null` when isomin > isomax', function() {
116+
gd = createIsosurfaceFig();
117+
gd.data[0].isomin = 0.9;
118+
gd.data[0].isomax = 0.1;
119+
120+
supplyAllDefaults(gd);
121+
expect(gd._fullData[0].isomin).toBe(null, 'isomin not set to default');
122+
expect(gd._fullData[0].isomax).toBe(null, 'isomax not set to default');
123+
});
124+
125+
it('@gl isosurface should accept cases where isomin === isomax', function() {
126+
gd = createIsosurfaceFig();
127+
gd.data[0].isomin = 1e-2;
128+
gd.data[0].isomax = 0.01;
129+
130+
supplyAllDefaults(gd);
131+
expect(gd._fullData[0].isomin).not.toBe(null, 'isomin not set');
132+
expect(gd._fullData[0].isomax).not.toBe(null, 'isomax not set');
133+
});
134+
135+
});
136+
137+
describe('mesh_generation', function() {
138+
139+
var gd;
140+
141+
beforeEach(function() {
142+
gd = createGraphDiv();
143+
});
144+
145+
afterEach(function() {
146+
Plotly.purge(gd);
147+
destroyGraphDiv();
148+
});
149+
150+
function assertPositions(exp, msg) {
151+
expect(gd._fullLayout.scene._scene.glplot.objects[0].positions.length).toBe(exp, msg);
152+
}
153+
154+
function assertCells(exp, msg) {
155+
expect(gd._fullLayout.scene._scene.glplot.objects[0].cells.length).toBe(exp, msg);
156+
}
157+
120158
it('@gl isosurface should create no iso-surface and set `gl-positions: []` for traces when all the data is between isomin and isomax', function(done) {
121159
var fig = createIsosurfaceFig();
122160
var data = fig.data[0];
@@ -159,75 +197,21 @@ describe('Test isosurface', function() {
159197
.then(done);
160198
});
161199

162-
it('@gl isosurface should be invisible when the vertex arrays are not arrays', function(done) {
163-
164-
var keysToChange = ['x', 'y', 'z', 'value'];
165-
var casesToCheck = [0, 1, true, false, NaN, Infinity, -Infinity, null, undefined, [], {}, '', 'text'];
166-
167-
function _testUsing(k, q) {
168-
assertVisibility(false, 'to be invisible after changing key: ' + keysToChange[k]) + ' to: ' + casesToCheck[q];
169-
}
170-
171-
keysToChange.forEach(function(k) {
172-
for(var q = 0; q < casesToCheck.length; q++) {
173-
174-
var fig = createIsosurfaceFig();
175-
fig.data[0][k] = casesToCheck[q];
176-
177-
Plotly.plot(gd, fig)
178-
.then(_testUsing)
179-
.catch(failTest)
180-
.then(done);
181-
}
182-
});
183-
});
184-
185-
it('@gl isosurface should not set `visible: false` when isomin > isomax', function(done) {
186-
var fig = createIsosurfaceFig();
187-
fig.data[0].isomin = 0.9;
188-
fig.data[0].isomax = 0.1;
200+
});
189201

190-
Plotly.plot(gd, createIsosurfaceFig())
191-
.then(function() {
192-
assertVisibility(true, 'to be visible');
193-
})
194-
.catch(failTest)
195-
.then(done);
196-
});
202+
describe('restyle', function() {
197203

198-
it('@gl isosurface should set `isomin: null` and `isomax: null` when isomin > isomax', function(done) {
199-
var fig = createIsosurfaceFig();
200-
fig.data[0].isomin = 0.9;
201-
fig.data[0].isomax = 0.1;
204+
var gd;
202205

203-
Plotly.plot(gd, fig)
204-
.then(function() {
205-
expect(gd._fullData[0].isomin).toBe(null, 'isomin not set to default');
206-
expect(gd._fullData[0].isomax).toBe(null, 'isomax not set to default');
207-
})
208-
.catch(failTest)
209-
.then(done);
206+
beforeEach(function() {
207+
gd = createGraphDiv();
210208
});
211209

212-
it('@gl isosurface should accept cases where isomin === isomax', function(done) {
213-
var fig = createIsosurfaceFig();
214-
fig.data[0].isomin = 1e-2;
215-
fig.data[0].isomax = 0.01;
216-
217-
Plotly.plot(gd, fig)
218-
.then(function() {
219-
expect(gd._fullData[0].isomin).not.toBe(null, 'isomin not set');
220-
expect(gd._fullData[0].isomax).not.toBe(null, 'isomax not set');
221-
})
222-
.catch(failTest)
223-
.then(done);
210+
afterEach(function() {
211+
Plotly.purge(gd);
212+
destroyGraphDiv();
224213
});
225214

226-
});
227-
228-
229-
describe('restyle', function() {
230-
231215
it('should clear *cauto* when restyle *cmin* and/or *cmax*', function(done) {
232216

233217
function _assert(user, full) {

0 commit comments

Comments
 (0)