Skip to content

Commit

Permalink
refactor(test): handling assert fail messages in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyGlt committed May 24, 2023
1 parent a8dfb36 commit 1131abe
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 82 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The following people have contributed to iTowns.

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

* [Oslandia](http://www.oslandia.com)
* [Vincent Picavet](https://github.com/vpicavet)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/3dtileslayerprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('3Dtiles layer', function () {
.then((layer) => {
assert.equal(layer.root.children.length, 1);
done();
}, done);
}).catch(done);
});
it('preUpdate 3dtiles layer', function () {
const elements = threedTilesLayer.preUpdate(context, new Set([threedTilesLayer]));
Expand Down
2 changes: 1 addition & 1 deletion test/unit/3dtileslayerprocessbatchtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ describe('3Dtiles batch table', function () {
const batchLength = viewer.getLayerById('3d-tiles-bt-hierarchy').root.batchTable.batchLength;
assert.equal(batchLength, 30);
done();
}, done);
}).catch(done);
});
});
14 changes: 7 additions & 7 deletions test/unit/cameraUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('Camera utils unit test', function () {
assert.ok(equalToFixed(result.coord.longitude, params.coord.longitude, 4));
assert.ok(equalToFixed(result.coord.latitude, params.coord.latitude, 4));
done();
}, done);
}).catch(done);
});
it('should set range like expected', function (done) {
const params = { range: 10000 };
Expand All @@ -73,7 +73,7 @@ describe('Camera utils unit test', function () {
const range = result.range;
assert.ok(equalToFixed(range, params.range, 1));
done();
}, done);
}).catch(done);
});
it('should look at coordinate like expected', function (done) {
const params = { coord: coord.clone() };
Expand All @@ -83,23 +83,23 @@ describe('Camera utils unit test', function () {
assert.ok(equalToFixed(result.coord.longitude, params.coord.longitude, 4));
assert.ok(equalToFixed(result.coord.latitude, params.coord.latitude, 4));
done();
}, done);
}).catch(done);
});
it('should tilt like expected', function (done) {
const params = { tilt: 38 };
CameraUtils.transformCameraToLookAtTarget(view, camera, params)
.then((result) => {
assert.ok(equalToFixed(result.tilt, params.tilt, 4));
done();
}, done);
}).catch(done);
});
it('should heading like expected', function (done) {
const params = { heading: 147 };
CameraUtils.transformCameraToLookAtTarget(view, camera, params)
.then((result) => {
assert.ok(equalToFixed(result.heading, params.heading, 4));
done();
}, done);
}).catch(done);
});
it('should heading, tilt, range and coordinate like expected', function (done) {
const params = { heading: 17, tilt: 80, range: 20000, coord: coord.clone() };
Expand All @@ -112,7 +112,7 @@ describe('Camera utils unit test', function () {
assert.ok(equalToFixed(result.coord.longitude, params.coord.longitude, 4));
assert.ok(equalToFixed(result.coord.latitude, params.coord.latitude, 4));
done();
}, done);
}).catch(done);
});

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

Expand Down
16 changes: 8 additions & 8 deletions test/unit/dataSourceProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('Provide in Sources', function () {
assert.equal(textures[0].extent.row, 511);
assert.equal(textures[0].extent.col, 512);
done();
}, done);
}).catch(done);
});

it('should get wmts texture elevation with DataSourceProvider', (done) => {
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('Provide in Sources', function () {
assert.equal(textures[0].extent.row, 511);
assert.equal(textures[0].extent.col, 512);
done();
}, done);
}).catch(done);
});
it('should get wms texture with DataSourceProvider', (done) => {
colorlayer.source = new WMSSource({
Expand Down Expand Up @@ -200,7 +200,7 @@ describe('Provide in Sources', function () {
assert.equal(e.north, tile.extent.north);
assert.equal(e.south, tile.extent.south);
done();
}, done);
}).catch(done);
});
it('should get 4 TileMesh from TileProvider', (done) => {
const tile = new TileMesh(geom, material, planarlayer, extent, zoom);
Expand All @@ -217,7 +217,7 @@ describe('Provide in Sources', function () {
assert.equal(tiles[0].extent.north, tile.extent.north);
assert.equal(tiles[0].extent.south, tile.extent.north * 0.5);
done();
}, done);
}).catch(done);
});
it('should get 3 meshs with WFS source and DataSourceProvider', (done) => {
const tile = new TileMesh(geom, material, planarlayer, extent, featureLayer.zoom.min);
Expand All @@ -234,7 +234,7 @@ describe('Provide in Sources', function () {
.then((features) => {
assert.equal(features[0].meshes.children.length, 4);
done();
}, done);
}).catch(done);
});

it('should get 1 mesh with WFS source and DataSourceProvider and mergeFeatures == true', (done) => {
Expand All @@ -260,7 +260,7 @@ describe('Provide in Sources', function () {
assert.equal(features[0].meshes.children[1].children.length, 0);
assert.equal(featureCountByCb, 2);
done();
}, done);
}).catch(done);
});
it('should get 1 texture with WFS source and DataSourceProvider', (done) => {
const tile = new TileMesh(
Expand Down Expand Up @@ -299,7 +299,7 @@ describe('Provide in Sources', function () {
assert.equal(textures.length, 1);
assert.ok(textures[0].isTexture);
done();
}, done);
}).catch(done);
});

it('should get updated RasterLayer', (done) => {
Expand Down Expand Up @@ -331,6 +331,6 @@ describe('Provide in Sources', function () {
tile.material.updateLayersUniforms();
assert.equal(tile.material.uniforms.colorTextures.value[0].extent.zoom, 10);
done();
}, done);
}).catch(done);
});
});
4 changes: 2 additions & 2 deletions test/unit/demutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('DemUtils', function () {
.then((l) => {
assert.equal('worldelevation', l.id);
done();
}, done);
}).catch(done);
});
const tiles = [];
const extent = new Extent('EPSG:4326', 5.625, 11.25, 45, 50.625);
Expand All @@ -69,7 +69,7 @@ describe('DemUtils', function () {
.then(() => {
assert.equal(nodeLayer.textures[0].image.data[0], 357.3833923339844);
done();
}, done);
}).catch(done);
});

it('get elevation value at with PRECISE_READ_Z', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/entwine.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Entwine Point Tile', function () {
source.whenReady
.then(() => {
done();
}, done);
}).catch(done);
});

describe('Layer', function () {
Expand All @@ -45,7 +45,7 @@ describe('Entwine Point Tile', function () {
View.prototype.addLayer.call(view, layer)
.then(() => {
done();
}, done);
}).catch(done);
});

it('pre updates and finds the root', () => {
Expand All @@ -70,7 +70,7 @@ describe('Entwine Point Tile', function () {
.then(() => {
done();
});
}, done);
}).catch(done);
});

it('post updates', function () {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/feature2mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Feature2Mesh', function () {
extentSize.x * extentSize.y,
computeAreaOfMesh(mesh.children[0]));
done();
}, done);
}).catch(done);
});

it('square mesh area should match geometry extent minus holes', function (done) {
Expand All @@ -54,7 +54,7 @@ describe('Feature2Mesh', function () {
noHoleArea - holeArea,
meshWithHoleArea);
done();
}, done);
}).catch(done);
});

it('convert points, lines and mesh', function (done) {
Expand All @@ -64,6 +64,6 @@ describe('Feature2Mesh', function () {
assert.equal(mesh.children[1].type, 'Line');
assert.equal(mesh.children[2].type, 'Mesh');
done();
}, done);
}).catch(done);
});
});
12 changes: 6 additions & 6 deletions test/unit/featureUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('FeaturesUtils', function () {
promise.then((collection) => {
assert.equal(collection.features.length, 3);
done();
}, done);
}).catch(done);
});

it('should correctly compute extent geojson', function (done) {
Expand All @@ -24,7 +24,7 @@ describe('FeaturesUtils', function () {
assert.equal(extent.south, 42.91620643817353);
assert.equal(extent.north, 43.72744458647463);
done();
}, done);
}).catch(done);
});

it('should correctly filter point', function (done) {
Expand All @@ -34,7 +34,7 @@ describe('FeaturesUtils', function () {
assert.equal(filter.length, 1.0);
assert.equal(filter[0].type == FEATURE_TYPES.POINT, 1.0);
done();
}, done);
}).catch(done);
});

it('should correctly filter polygon', function (done) {
Expand All @@ -44,7 +44,7 @@ describe('FeaturesUtils', function () {
assert.equal(filter.length, 1.0);
assert.equal(filter[0].type == FEATURE_TYPES.POLYGON, 1.0);
done();
}, done);
}).catch(done);
});

it('should correctly filter line', function (done) {
Expand All @@ -54,13 +54,13 @@ describe('FeaturesUtils', function () {
assert.equal(filter.length, 1.0);
assert.equal(filter[0].type == FEATURE_TYPES.LINE, 1.0);
done();
}, done);
}).catch(done);
});

it('should remember individual feature properties', function (done) {
promise.then((collection) => {
assert.equal(collection.features[2].geometries[0].properties.my_prop, 14);
done();
}, done);
}).catch(done);
});
});
10 changes: 5 additions & 5 deletions test/unit/featuregeometrylayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Layer with Feature process', function () {
.then((layer) => {
assert.ok(layer);
done();
}, done);
}).catch(done);
});
it('update', function (done) {
ariege.whenReady
Expand All @@ -85,15 +85,15 @@ describe('Layer with Feature process', function () {
assert.equal(ariege.object3d.children.length, 1);
done();
});
}, done);
}).catch(done);
});

it('add layer no proj4', function (done) {
viewer.addLayer(ariegeNoProj4)
.then((layer) => {
assert.ok(layer);
done();
}, done);
}).catch(done);
});

it('update no proj4', function (done) {
Expand All @@ -106,7 +106,7 @@ describe('Layer with Feature process', function () {
assert.equal(ariegeNoProj4.object3d.children.length, 1);
done();
});
}, done);
}).catch(done);
});

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

assert.ok(error < 1e-5);
done();
}, done);
}).catch(done);
});
});

14 changes: 7 additions & 7 deletions test/unit/featuregeometrylayererror.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,25 @@ files.forEach((geojson, i) => {
layerProj4.whenReady
.then(() => {
tile.visible = true;
layerProj4.update(context, layerProj4, tile)
return layerProj4.update(context, layerProj4, tile)
.then(() => {
assert.equal(layerProj4.object3d.children.length, 1);
done();
}, done);
}, done);
});
}).catch(done);
});

it('update without proj4', function (done) {
layerNoProj4.whenReady
.then(() => {
tile.visible = true;
context.layer = layerNoProj4;
layerNoProj4.update(context, layerNoProj4, tile)
return layerNoProj4.update(context, layerNoProj4, tile)
.then(() => {
assert.equal(layerNoProj4.object3d.children.length, 1);
done();
}, done);
}, done);
});
}).catch(done);
});

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

assert.ok(error < max_error);
done();
}, done);
}).catch(done);
});
});
});
4 changes: 2 additions & 2 deletions test/unit/geoidlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('GlobeView', function () {
view.addLayer(geoidLayer)
.then(() => {
done();
}, done);
}).catch(done);
});

it('update geoid layer', function (done) {
Expand All @@ -55,6 +55,6 @@ describe('GlobeView', function () {
assert.equal(tile.geoidHeight, 45.72800064087844);
done();
});
}, done);
}).catch(done);
});
});
Loading

0 comments on commit 1131abe

Please sign in to comment.