Skip to content

Commit 1131abe

Browse files
committed
refactor(test): handling assert fail messages in tests
1 parent a8dfb36 commit 1131abe

20 files changed

+82
-82
lines changed

CONTRIBUTORS.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The following people have contributed to iTowns.
1616

1717
* [CIRIL Group](https://www.cirilgroup.com/en/):
1818
* [Vincent Jaillot](https://github.com/jailln)
19+
* [Anthony Gullient](https://github.com/AnthonyGlt)
1920

2021
* [Oslandia](http://www.oslandia.com)
2122
* [Vincent Picavet](https://github.com/vpicavet)

test/unit/3dtileslayerprocess.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('3Dtiles layer', function () {
3535
.then((layer) => {
3636
assert.equal(layer.root.children.length, 1);
3737
done();
38-
}, done);
38+
}).catch(done);
3939
});
4040
it('preUpdate 3dtiles layer', function () {
4141
const elements = threedTilesLayer.preUpdate(context, new Set([threedTilesLayer]));

test/unit/3dtileslayerprocessbatchtable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ describe('3Dtiles batch table', function () {
4444
const batchLength = viewer.getLayerById('3d-tiles-bt-hierarchy').root.batchTable.batchLength;
4545
assert.equal(batchLength, 30);
4646
done();
47-
}, done);
47+
}).catch(done);
4848
});
4949
});

test/unit/cameraUtils.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('Camera utils unit test', function () {
6464
assert.ok(equalToFixed(result.coord.longitude, params.coord.longitude, 4));
6565
assert.ok(equalToFixed(result.coord.latitude, params.coord.latitude, 4));
6666
done();
67-
}, done);
67+
}).catch(done);
6868
});
6969
it('should set range like expected', function (done) {
7070
const params = { range: 10000 };
@@ -73,7 +73,7 @@ describe('Camera utils unit test', function () {
7373
const range = result.range;
7474
assert.ok(equalToFixed(range, params.range, 1));
7575
done();
76-
}, done);
76+
}).catch(done);
7777
});
7878
it('should look at coordinate like expected', function (done) {
7979
const params = { coord: coord.clone() };
@@ -83,23 +83,23 @@ describe('Camera utils unit test', function () {
8383
assert.ok(equalToFixed(result.coord.longitude, params.coord.longitude, 4));
8484
assert.ok(equalToFixed(result.coord.latitude, params.coord.latitude, 4));
8585
done();
86-
}, done);
86+
}).catch(done);
8787
});
8888
it('should tilt like expected', function (done) {
8989
const params = { tilt: 38 };
9090
CameraUtils.transformCameraToLookAtTarget(view, camera, params)
9191
.then((result) => {
9292
assert.ok(equalToFixed(result.tilt, params.tilt, 4));
9393
done();
94-
}, done);
94+
}).catch(done);
9595
});
9696
it('should heading like expected', function (done) {
9797
const params = { heading: 147 };
9898
CameraUtils.transformCameraToLookAtTarget(view, camera, params)
9999
.then((result) => {
100100
assert.ok(equalToFixed(result.heading, params.heading, 4));
101101
done();
102-
}, done);
102+
}).catch(done);
103103
});
104104
it('should heading, tilt, range and coordinate like expected', function (done) {
105105
const params = { heading: 17, tilt: 80, range: 20000, coord: coord.clone() };
@@ -112,7 +112,7 @@ describe('Camera utils unit test', function () {
112112
assert.ok(equalToFixed(result.coord.longitude, params.coord.longitude, 4));
113113
assert.ok(equalToFixed(result.coord.latitude, params.coord.latitude, 4));
114114
done();
115-
}, done);
115+
}).catch(done);
116116
});
117117

118118
// TODO: to verify and recode
@@ -129,7 +129,7 @@ describe('Camera utils unit test', function () {
129129
assert.ok(equalToFixed(result.coord.longitude, params.coord.longitude, 4));
130130
assert.ok(equalToFixed(result.coord.latitude, params.coord.latitude, 4));
131131
done();
132-
}, done);// neither here
132+
}).catch(done);// neither here
133133
});
134134
*/
135135

test/unit/dataSourceProvider.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe('Provide in Sources', function () {
137137
assert.equal(textures[0].extent.row, 511);
138138
assert.equal(textures[0].extent.col, 512);
139139
done();
140-
}, done);
140+
}).catch(done);
141141
});
142142

143143
it('should get wmts texture elevation with DataSourceProvider', (done) => {
@@ -167,7 +167,7 @@ describe('Provide in Sources', function () {
167167
assert.equal(textures[0].extent.row, 511);
168168
assert.equal(textures[0].extent.col, 512);
169169
done();
170-
}, done);
170+
}).catch(done);
171171
});
172172
it('should get wms texture with DataSourceProvider', (done) => {
173173
colorlayer.source = new WMSSource({
@@ -200,7 +200,7 @@ describe('Provide in Sources', function () {
200200
assert.equal(e.north, tile.extent.north);
201201
assert.equal(e.south, tile.extent.south);
202202
done();
203-
}, done);
203+
}).catch(done);
204204
});
205205
it('should get 4 TileMesh from TileProvider', (done) => {
206206
const tile = new TileMesh(geom, material, planarlayer, extent, zoom);
@@ -217,7 +217,7 @@ describe('Provide in Sources', function () {
217217
assert.equal(tiles[0].extent.north, tile.extent.north);
218218
assert.equal(tiles[0].extent.south, tile.extent.north * 0.5);
219219
done();
220-
}, done);
220+
}).catch(done);
221221
});
222222
it('should get 3 meshs with WFS source and DataSourceProvider', (done) => {
223223
const tile = new TileMesh(geom, material, planarlayer, extent, featureLayer.zoom.min);
@@ -234,7 +234,7 @@ describe('Provide in Sources', function () {
234234
.then((features) => {
235235
assert.equal(features[0].meshes.children.length, 4);
236236
done();
237-
}, done);
237+
}).catch(done);
238238
});
239239

240240
it('should get 1 mesh with WFS source and DataSourceProvider and mergeFeatures == true', (done) => {
@@ -260,7 +260,7 @@ describe('Provide in Sources', function () {
260260
assert.equal(features[0].meshes.children[1].children.length, 0);
261261
assert.equal(featureCountByCb, 2);
262262
done();
263-
}, done);
263+
}).catch(done);
264264
});
265265
it('should get 1 texture with WFS source and DataSourceProvider', (done) => {
266266
const tile = new TileMesh(
@@ -299,7 +299,7 @@ describe('Provide in Sources', function () {
299299
assert.equal(textures.length, 1);
300300
assert.ok(textures[0].isTexture);
301301
done();
302-
}, done);
302+
}).catch(done);
303303
});
304304

305305
it('should get updated RasterLayer', (done) => {
@@ -331,6 +331,6 @@ describe('Provide in Sources', function () {
331331
tile.material.updateLayersUniforms();
332332
assert.equal(tile.material.uniforms.colorTextures.value[0].extent.zoom, 10);
333333
done();
334-
}, done);
334+
}).catch(done);
335335
});
336336
});

test/unit/demutils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('DemUtils', function () {
5151
.then((l) => {
5252
assert.equal('worldelevation', l.id);
5353
done();
54-
}, done);
54+
}).catch(done);
5555
});
5656
const tiles = [];
5757
const extent = new Extent('EPSG:4326', 5.625, 11.25, 45, 50.625);
@@ -69,7 +69,7 @@ describe('DemUtils', function () {
6969
.then(() => {
7070
assert.equal(nodeLayer.textures[0].image.data[0], 357.3833923339844);
7171
done();
72-
}, done);
72+
}).catch(done);
7373
});
7474

7575
it('get elevation value at with PRECISE_READ_Z', () => {

test/unit/entwine.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Entwine Point Tile', function () {
1818
source.whenReady
1919
.then(() => {
2020
done();
21-
}, done);
21+
}).catch(done);
2222
});
2323

2424
describe('Layer', function () {
@@ -45,7 +45,7 @@ describe('Entwine Point Tile', function () {
4545
View.prototype.addLayer.call(view, layer)
4646
.then(() => {
4747
done();
48-
}, done);
48+
}).catch(done);
4949
});
5050

5151
it('pre updates and finds the root', () => {
@@ -70,7 +70,7 @@ describe('Entwine Point Tile', function () {
7070
.then(() => {
7171
done();
7272
});
73-
}, done);
73+
}).catch(done);
7474
});
7575

7676
it('post updates', function () {

test/unit/feature2mesh.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('Feature2Mesh', function () {
3939
extentSize.x * extentSize.y,
4040
computeAreaOfMesh(mesh.children[0]));
4141
done();
42-
}, done);
42+
}).catch(done);
4343
});
4444

4545
it('square mesh area should match geometry extent minus holes', function (done) {
@@ -54,7 +54,7 @@ describe('Feature2Mesh', function () {
5454
noHoleArea - holeArea,
5555
meshWithHoleArea);
5656
done();
57-
}, done);
57+
}).catch(done);
5858
});
5959

6060
it('convert points, lines and mesh', function (done) {
@@ -64,6 +64,6 @@ describe('Feature2Mesh', function () {
6464
assert.equal(mesh.children[1].type, 'Line');
6565
assert.equal(mesh.children[2].type, 'Mesh');
6666
done();
67-
}, done);
67+
}).catch(done);
6868
});
6969
});

test/unit/featureUtils.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('FeaturesUtils', function () {
1313
promise.then((collection) => {
1414
assert.equal(collection.features.length, 3);
1515
done();
16-
}, done);
16+
}).catch(done);
1717
});
1818

1919
it('should correctly compute extent geojson', function (done) {
@@ -24,7 +24,7 @@ describe('FeaturesUtils', function () {
2424
assert.equal(extent.south, 42.91620643817353);
2525
assert.equal(extent.north, 43.72744458647463);
2626
done();
27-
}, done);
27+
}).catch(done);
2828
});
2929

3030
it('should correctly filter point', function (done) {
@@ -34,7 +34,7 @@ describe('FeaturesUtils', function () {
3434
assert.equal(filter.length, 1.0);
3535
assert.equal(filter[0].type == FEATURE_TYPES.POINT, 1.0);
3636
done();
37-
}, done);
37+
}).catch(done);
3838
});
3939

4040
it('should correctly filter polygon', function (done) {
@@ -44,7 +44,7 @@ describe('FeaturesUtils', function () {
4444
assert.equal(filter.length, 1.0);
4545
assert.equal(filter[0].type == FEATURE_TYPES.POLYGON, 1.0);
4646
done();
47-
}, done);
47+
}).catch(done);
4848
});
4949

5050
it('should correctly filter line', function (done) {
@@ -54,13 +54,13 @@ describe('FeaturesUtils', function () {
5454
assert.equal(filter.length, 1.0);
5555
assert.equal(filter[0].type == FEATURE_TYPES.LINE, 1.0);
5656
done();
57-
}, done);
57+
}).catch(done);
5858
});
5959

6060
it('should remember individual feature properties', function (done) {
6161
promise.then((collection) => {
6262
assert.equal(collection.features[2].geometries[0].properties.my_prop, 14);
6363
done();
64-
}, done);
64+
}).catch(done);
6565
});
6666
});

test/unit/featuregeometrylayer.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('Layer with Feature process', function () {
7474
.then((layer) => {
7575
assert.ok(layer);
7676
done();
77-
}, done);
77+
}).catch(done);
7878
});
7979
it('update', function (done) {
8080
ariege.whenReady
@@ -85,15 +85,15 @@ describe('Layer with Feature process', function () {
8585
assert.equal(ariege.object3d.children.length, 1);
8686
done();
8787
});
88-
}, done);
88+
}).catch(done);
8989
});
9090

9191
it('add layer no proj4', function (done) {
9292
viewer.addLayer(ariegeNoProj4)
9393
.then((layer) => {
9494
assert.ok(layer);
9595
done();
96-
}, done);
96+
}).catch(done);
9797
});
9898

9999
it('update no proj4', function (done) {
@@ -106,7 +106,7 @@ describe('Layer with Feature process', function () {
106106
assert.equal(ariegeNoProj4.object3d.children.length, 1);
107107
done();
108108
});
109-
}, done);
109+
}).catch(done);
110110
});
111111

112112
it('parsing error without proj4 should be inferior to 1e-5 meter', function (done) {
@@ -129,7 +129,7 @@ describe('Layer with Feature process', function () {
129129

130130
assert.ok(error < 1e-5);
131131
done();
132-
}, done);
132+
}).catch(done);
133133
});
134134
});
135135

test/unit/featuregeometrylayererror.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,25 @@ files.forEach((geojson, i) => {
6868
layerProj4.whenReady
6969
.then(() => {
7070
tile.visible = true;
71-
layerProj4.update(context, layerProj4, tile)
71+
return layerProj4.update(context, layerProj4, tile)
7272
.then(() => {
7373
assert.equal(layerProj4.object3d.children.length, 1);
7474
done();
75-
}, done);
76-
}, done);
75+
});
76+
}).catch(done);
7777
});
7878

7979
it('update without proj4', function (done) {
8080
layerNoProj4.whenReady
8181
.then(() => {
8282
tile.visible = true;
8383
context.layer = layerNoProj4;
84-
layerNoProj4.update(context, layerNoProj4, tile)
84+
return layerNoProj4.update(context, layerNoProj4, tile)
8585
.then(() => {
8686
assert.equal(layerNoProj4.object3d.children.length, 1);
8787
done();
88-
}, done);
89-
}, done);
88+
});
89+
}).catch(done);
9090
});
9191

9292
it(`parsing error without proj4 should be inferior to ${max_error} meter`, function (done) {
@@ -118,7 +118,7 @@ files.forEach((geojson, i) => {
118118

119119
assert.ok(error < max_error);
120120
done();
121-
}, done);
121+
}).catch(done);
122122
});
123123
});
124124
});

test/unit/geoidlayer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('GlobeView', function () {
4444
view.addLayer(geoidLayer)
4545
.then(() => {
4646
done();
47-
}, done);
47+
}).catch(done);
4848
});
4949

5050
it('update geoid layer', function (done) {
@@ -55,6 +55,6 @@ describe('GlobeView', function () {
5555
assert.equal(tile.geoidHeight, 45.72800064087844);
5656
done();
5757
});
58-
}, done);
58+
}).catch(done);
5959
});
6060
});

0 commit comments

Comments
 (0)