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 Sep 12, 2023
1 parent 363f137 commit e88b0cc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions src/Layer/C3DTilesLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ export const C3DTILES_LAYER_EVENTS = {

const update = process3dTilesNode();

// function find the tile id from an object
function findTileID(object) {
let currentObject = object;
let result = currentObject.tileId;
while (isNaN(result) && currentObject.parent) {
currentObject = currentObject.parent;
result = currentObject.tileId;
}
return result;
}

class C3DTilesLayer extends GeometryLayer {
#fillColorMaterialsBuffer;
/**
Expand Down Expand Up @@ -228,6 +239,7 @@ class C3DTilesLayer extends GeometryLayer {
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 All @@ -244,18 +256,6 @@ class C3DTilesLayer extends GeometryLayer {
return null;
}

// function find the tile id from an object
function findTileID(object) {
let currentObject = object;
let result = currentObject.tileId;
while (isNaN(result) && currentObject.parent) {
currentObject = currentObject.parent;
result = currentObject.tileId;
}

return result;
}

const tileId = findTileID(closestIntersect.object);
// face is a Face3 object of THREE which is a
// triangular face. face.a is its first vertex
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 e88b0cc

Please sign in to comment.