Skip to content

Commit

Permalink
refactor(test): unit test clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Dec 11, 2023
1 parent ac9cea4 commit 69d5ad8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/Layer/C3DTilesLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const update = process3dTilesNode();

/**
* Find tileId of object
*
* @param {THREE.Object3D} object - object
*
* @returns {number} tileId
*/
function findTileID(object) {
Expand All @@ -41,14 +41,13 @@ function findTileID(object) {
currentObject = currentObject.parent;
result = currentObject.tileId;
}

return result;
}

/**
* Check if object3d has feature
*
* @param {THREE.Object3D} object3d - object3d to check
*
* @returns {boolean} - true if object3d has feature
*/
function object3DHasFeature(object3d) {
Expand Down Expand Up @@ -233,6 +232,7 @@ class C3DTilesLayer extends GeometryLayer {
* organization of 3DTiles:
* https://github.com/MEPP-team/RICT/blob/master/Doc/iTowns/Doc.md#itowns-internal-organisation-of-3d-tiles-data
* @param {THREE.Object3D} object - a 3D geometric object
*
* @returns {C3DTBatchTable} - the batch table of the object
*/
findBatchTable(object) {
Expand All @@ -250,11 +250,13 @@ class C3DTilesLayer extends GeometryLayer {
* targets picked under specified coordinates. Intersects can be
* computed with view.pickObjectsAt(..). See fillHTMLWithPickingInfo()
* in 3dTilesHelper.js for an example.
*
* @returns {C3DTileFeature} - the closest C3DTileFeature of the intersects array
*/
getC3DTileFeatureFromIntersectsArray(intersects) {
// find closest intersect with an attributes _BATCHID + face != undefined
let closestIntersect = null;

for (let index = 0; index < intersects.length; index++) {
const i = intersects[index];
if (i.object.geometry &&
Expand Down Expand Up @@ -296,7 +298,6 @@ class C3DTilesLayer extends GeometryLayer {

/**
* Initialize C3DTileFeatures from tileContent
*
* @param {THREE.Object3D} tileContent - tile as THREE.Object3D
*/
initC3DTileFeatures(tileContent) {
Expand Down Expand Up @@ -365,8 +366,8 @@ class C3DTilesLayer extends GeometryLayer {
/**
* Update style of the C3DTFeatures, an allowList of tile id can be passed to only update certain tile.
* Note that this function only update THREE.Object3D materials, in order to see style changes you should call view.notifyChange()
*
* @param {Array<number>|null} [allowTileIdList] - tile ids to allow in updateStyle computation if null all tiles are updated
*
* @returns {boolean} true if style updated false otherwise
*/
updateStyle(allowTileIdList = null) {
Expand Down
6 changes: 3 additions & 3 deletions test/functional/3dtiles_batch_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('3dtiles_batch_table', function _() {
// Verifies that the batch id, batch table and batch table hierarchy
// extension picked information are correct for object at { x: 218, y: 90 }
it('should return the batch table and batch hierarchy picked information',
async () => {
async function _it() {
// Picks the object at (218,90) and gets its closest c3DTileFeature
const pickResult = await page.evaluate(
() => {
Expand Down Expand Up @@ -70,8 +70,8 @@ describe('3dtiles_batch_table', function _() {
},
},
};
const expectedBatchId = 29;
assert.deepStrictEqual(pickResult.batchId, expectedBatchId);

assert.equal(pickResult.batchId, 29);
assert.deepStrictEqual(pickResult.info, expectedPickingInfo);
});
});
2 changes: 1 addition & 1 deletion test/unit/vectortiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('Vector tiles', function () {
});
});

it('loads the style from a file', (done) => {
it('loads the style from a file', function _(done) {
const source = new VectorTilesSource({
style: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/vectortiles/style.json',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
Expand Down

0 comments on commit 69d5ad8

Please sign in to comment.