diff --git a/app/engine.test.js b/app/engine.test.js index b8eb5c6..dd499d0 100644 --- a/app/engine.test.js +++ b/app/engine.test.js @@ -10,6 +10,9 @@ class TestServer extends Server { super(); this.data = {}; } + async readAsset() { + return new ArrayBuffer(0); + } async readData(path) { if (path in this.data) { return this.data[path]; @@ -34,16 +37,17 @@ test('visibility-based updates', async () => { Position: {x: (RESOLUTION.x * 1.5) + 32 - 3, y: 20}, VisibleAabb: {}, })); + const {entity: mainEntity} = engine.connectedPlayers.get(0); // Tick and get update. Should be a full update. engine.tick(1); expect(engine.updateFor(0)) - .to.deep.include({2: {MainEntity: {}, ...ecs.get(2).toJSON()}, 3: ecs.get(3).toJSON()}); + .to.deep.include({[mainEntity.id]: {MainEntity: {}, ...ecs.get(mainEntity.id).toJSON()}, [entity.id]: ecs.get(entity.id).toJSON()}); engine.setClean(); // Tick and get update. Should be a partial update. engine.tick(1); expect(engine.updateFor(0)) .to.deep.include({ - 3: { + [entity.id]: { Position: {x: (RESOLUTION.x * 1.5) + 32 - 1}, VisibleAabb: { x0: 1199, @@ -55,11 +59,11 @@ test('visibility-based updates', async () => { // Tick and get update. Should remove the entity. engine.tick(1); expect(engine.updateFor(0)) - .to.deep.include({3: false}); + .to.deep.include({[entity.id]: false}); // Aim back toward visible area and tick. Should be a full update for that entity. engine.setClean(); entity.Forces.forceX = -1; engine.tick(1); expect(engine.updateFor(0)) - .to.deep.include({3: ecs.get(3).toJSON()}); + .to.deep.include({[entity.id]: ecs.get(entity.id).toJSON()}); });