From 0ced06da5fef25c669ebff850fcb428e02ba446c Mon Sep 17 00:00:00 2001 From: Eric Hebert Date: Sun, 11 Apr 2021 02:35:15 -0400 Subject: [PATCH] Removed old assert() hack Replaced with expect() - not all cases are fully idiomatic yet, but it's a good start --- test/test_utils.js | 5 - test/world.test.js | 414 ++++++++++++++++++++++++--------------------- 2 files changed, 220 insertions(+), 199 deletions(-) diff --git a/test/test_utils.js b/test/test_utils.js index fc0bf46..3ceb36f 100644 --- a/test/test_utils.js +++ b/test/test_utils.js @@ -14,8 +14,3 @@ export function has(it, target) { } return false } - -// TODO: Result of mocha/chai to jest upgrade, remove and use jest's "expect" -export function assert(value) { - expect(Boolean(value)).toBe(true) -} diff --git a/test/world.test.js b/test/world.test.js index 3b84220..9611daf 100644 --- a/test/world.test.js +++ b/test/world.test.js @@ -1,11 +1,11 @@ import { World } from '../index.js' import { Entity } from '../src/entity.js' -import { getSize, has, assert } from './test_utils.js' +import { getSize, has } from './test_utils.js' test('world: create a world', () => { const world = new World() - assert(world instanceof World) - assert(typeof world.component === 'function') + expect(world instanceof World).toBeTruthy() + expect(typeof world.component === 'function').toBeTruthy() }) test('world: create a world with options', () => { @@ -55,12 +55,12 @@ test('component: define a component', () => { } }) let ent = world.entity().set('position', 1, 2) - assert('position' in world.entities.componentClasses) - assert(Object.keys(world.entities.componentClasses).length == 1) - assert(ent.has('position')) - assert(ent.get('position').x === 1) - assert(ent.get('position').y === 2) - assert(ent.get('position').inc(5) === 6) + expect('position' in world.entities.componentClasses).toBeTruthy() + expect(Object.keys(world.entities.componentClasses).length == 1).toBeTruthy() + expect(ent.has('position')).toBeTruthy() + expect(ent.get('position').x === 1).toBeTruthy() + expect(ent.get('position').y === 2).toBeTruthy() + expect(ent.get('position').inc(5) === 6).toBeTruthy() // Using class syntax world.component( @@ -77,12 +77,12 @@ test('component: define a component', () => { } ) let ent2 = world.entity().set('velocity', 1, 2) - assert('velocity' in world.entities.componentClasses) - assert(Object.keys(world.entities.componentClasses).length == 2) - assert(ent2.has('velocity')) - assert(ent2.get('velocity').x === 1) - assert(ent2.get('velocity').y === 2) - assert(ent2.get('velocity').inc(5) === 6) + expect('velocity' in world.entities.componentClasses).toBeTruthy() + expect(Object.keys(world.entities.componentClasses).length == 2).toBeTruthy() + expect(ent2.has('velocity')).toBeTruthy() + expect(ent2.get('velocity').x === 1).toBeTruthy() + expect(ent2.get('velocity').y === 2).toBeTruthy() + expect(ent2.get('velocity').inc(5) === 6).toBeTruthy() // Should throw when calling "components" setter expect(() => (ent2.components = ['anything'])).toThrow() @@ -103,7 +103,7 @@ test('component: README example', () => { }) // Player now has reduced health - assert(player.get('health').value === 60) + expect(player.get('health').value === 60).toBeTruthy() }) test('component: define invalid components', () => { @@ -120,7 +120,7 @@ test('component: define invalid components', () => { expect(() => { world.component('invalid', 555) }).toThrow() - assert(Object.keys(world.entities.componentClasses).length === 0) + expect(Object.keys(world.entities.componentClasses).length === 0).toBeTruthy() }) test('component: use an empty component', () => { @@ -128,37 +128,37 @@ test('component: use an empty component', () => { let ent = world.entity().set('position', { x: 1, }) - assert(ent.has('position')) - assert(ent.get('position').x === 1) + expect(ent.has('position')).toBeTruthy() + expect(ent.get('position').x === 1).toBeTruthy() let ent2 = world.entity().set('velocity', { x: 2, }) - assert(ent2.has('velocity')) - assert(ent2.get('velocity').x === 2) + expect(ent2.has('velocity')).toBeTruthy() + expect(ent2.get('velocity').x === 2).toBeTruthy() ent2.set('velocity', { y: 3, }) - assert(ent2.get('velocity').x === undefined) - assert(ent2.get('velocity').y === 3) + expect(ent2.get('velocity').x === undefined).toBeTruthy() + expect(ent2.get('velocity').y === 3).toBeTruthy() ent2.get('velocity').x = 42 - assert(ent2.get('velocity').x === 42) - assert(ent2.get('velocity').y === 3) + expect(ent2.get('velocity').x === 42).toBeTruthy() + expect(ent2.get('velocity').y === 3).toBeTruthy() let ent3 = world.entity().set('singleValue', 5) - assert(ent3.has('singleValue')) - assert(ent3.get('singleValue') === 5) + expect(ent3.has('singleValue')).toBeTruthy() + expect(ent3.get('singleValue') === 5).toBeTruthy() ent3.set('singleValue', 500) - assert(ent3.get('singleValue') === 500) + expect(ent3.get('singleValue') === 500).toBeTruthy() let ent4 = world.entity().set('string', 'hello') - assert(ent4.has('string')) - assert(ent4.get('string') === 'hello') + expect(ent4.has('string')).toBeTruthy() + expect(ent4.get('string') === 'hello').toBeTruthy() ent4.set('string', 'goodbye') - assert(ent4.get('string') === 'goodbye') + expect(ent4.get('string') === 'goodbye').toBeTruthy() ent4.remove('string') - assert(!ent4.has('string')) + expect(!ent4.has('string')).toBeTruthy() }) test('component: test clearing with indexes', () => { @@ -178,11 +178,11 @@ test('component: test clearing with indexes', () => { let count = 0 world.each('position', ({ position }) => { - assert(position.x >= 1) - assert(position.y >= 2) + expect(position.x >= 1).toBeTruthy() + expect(position.y >= 2).toBeTruthy() ++count }) - assert(count === 3) + expect(count === 3).toBeTruthy() world.clear() @@ -193,7 +193,7 @@ test('component: test clearing with indexes', () => { world.each((_, ent) => { ++count }) - assert(count === 0) + expect(count === 0).toBeTruthy() }) test('component: test entity creation with constructor parameters', () => { @@ -206,21 +206,21 @@ test('component: test entity creation with constructor parameters', () => { this.texture = texture this.size = size this.constructorCalled = ++when - assert(texture && texture === this.texture) - assert(size && size === this.size) - assert(invalid === undefined) + expect(texture && texture === this.texture).toBeTruthy() + expect(size && size === this.size).toBeTruthy() + expect(invalid === undefined).toBeTruthy() // Regression in 0.3.0, fixed in 0.3.1 - assert(this.entity.get('sprite') === this) + expect(this.entity.get('sprite') === this).toBeTruthy() } } ) let ent = world.entity().set('sprite', 'test.png', 100) - assert(ent.get('sprite').constructorCalled === 1) - assert(ent.get('sprite').entity === ent) - assert(ent.get('sprite').texture === 'test.png') - assert(ent.get('sprite').size === 100) + expect(ent.get('sprite').constructorCalled === 1).toBeTruthy() + expect(ent.get('sprite').entity === ent).toBeTruthy() + expect(ent.get('sprite').texture === 'test.png').toBeTruthy() + expect(ent.get('sprite').size === 100).toBeTruthy() }) test('component: test clearing with onRemove', () => { @@ -240,13 +240,13 @@ test('component: test clearing with onRemove', () => { ) let ent = world.entity().set('sprite') - assert(spriteCount === 1) + expect(spriteCount === 1).toBeTruthy() let ent2 = world.entity().set('sprite') - assert(spriteCount === 2) + expect(spriteCount === 2).toBeTruthy() world.clear() - assert(spriteCount === 0) + expect(spriteCount === 0).toBeTruthy() }) test('component: test detach and attach', () => { @@ -266,40 +266,40 @@ test('component: test detach and attach', () => { ) let ent = world.entity().set('sprite').set('position', { x: 1 }) - assert(spriteCount === 1) + expect(spriteCount === 1).toBeTruthy() let ent2 = world.entity().set('sprite').set('position', { x: 2 }) - assert(spriteCount === 2) + expect(spriteCount === 2).toBeTruthy() // Test detaching - assert(ent.valid()) + expect(ent.valid()).toBeTruthy() ent.detach() - assert(!ent.valid()) - assert(spriteCount === 2) - assert(world.entities.entities.size === 1) - assert(getSize(world.each('position')) === 1) - assert(world.each('position').length === 1) - assert(world.each('position')[0].get('position').x === 2) - assert(ent.get('position').x === 1) + expect(!ent.valid()).toBeTruthy() + expect(spriteCount === 2).toBeTruthy() + expect(world.entities.entities.size === 1).toBeTruthy() + expect(getSize(world.each('position')) === 1).toBeTruthy() + expect(world.each('position').length === 1).toBeTruthy() + expect(world.each('position')[0].get('position').x === 2).toBeTruthy() + expect(ent.get('position').x === 1).toBeTruthy() // Test attaching ent.attach(world) - assert(ent.valid()) - assert(spriteCount === 2) - assert(world.entities.entities.size === 2) - assert(getSize(world.each('position')) === 2) - assert(world.each('position').length === 2) - assert(ent.get('position').x === 1) + expect(ent.valid()).toBeTruthy() + expect(spriteCount === 2).toBeTruthy() + expect(world.entities.entities.size === 2).toBeTruthy() + expect(getSize(world.each('position')) === 2).toBeTruthy() + expect(world.each('position').length === 2).toBeTruthy() + expect(ent.get('position').x === 1).toBeTruthy() // Test edge cases ent.detach() - assert(!ent.valid()) + expect(!ent.valid()).toBeTruthy() ent.detach() - assert(!ent.valid()) + expect(!ent.valid()).toBeTruthy() ent.attach() - assert(!ent.valid()) + expect(!ent.valid()).toBeTruthy() ent.attach(world) - assert(ent.valid()) + expect(ent.valid()).toBeTruthy() }) test('component: test detached entities', () => { @@ -309,48 +309,48 @@ test('component: test detached entities', () => { .set('sprite', { texture: 'image.png' }) .set('position', 5) - assert(ent.valid()) - assert(ent.has('sprite')) - assert(ent.has('position')) - assert(ent.get('sprite').texture === 'image.png') - assert(ent.get('position') === 5) + expect(ent.valid()).toBeTruthy() + expect(ent.has('sprite')).toBeTruthy() + expect(ent.has('position')).toBeTruthy() + expect(ent.get('sprite').texture === 'image.png').toBeTruthy() + expect(ent.get('position') === 5).toBeTruthy() ent.detach() - assert(!ent.valid()) - assert(ent.has('sprite')) - assert(ent.has('position')) - assert(ent.get('sprite').texture === 'image.png') - assert(ent.get('position') === 5) + expect(!ent.valid()).toBeTruthy() + expect(ent.has('sprite')).toBeTruthy() + expect(ent.has('position')).toBeTruthy() + expect(ent.get('sprite').texture === 'image.png').toBeTruthy() + expect(ent.get('position') === 5).toBeTruthy() ent.set('velocity', { x: 10 }) - assert(ent.has('velocity')) - assert(ent.get('velocity').x === 10) + expect(ent.has('velocity')).toBeTruthy() + expect(ent.get('velocity').x === 10).toBeTruthy() ent.set('position', 6) - assert(ent.has('position')) - assert(ent.get('position') === 6) + expect(ent.has('position')).toBeTruthy() + expect(ent.get('position') === 6).toBeTruthy() ent.remove('position') - assert(!ent.has('position')) + expect(!ent.has('position')).toBeTruthy() // Create entity outside of the world let ent2 = new Entity() - assert(!ent2.valid()) + expect(!ent2.valid()).toBeTruthy() ent2.set('velocity', { x: 30 }) ent2.set('position', 7) - assert(ent2.has('velocity', 'position')) - assert(ent2.get('velocity').x === 30) - assert(ent2.get('position') === 7) + expect(ent2.has('velocity', 'position')).toBeTruthy() + expect(ent2.get('velocity').x === 30).toBeTruthy() + expect(ent2.get('position') === 7).toBeTruthy() ent2.remove('velocity', 'position') - assert(!ent2.has('velocity')) - assert(!ent2.has('position')) + expect(!ent2.has('velocity')).toBeTruthy() + expect(!ent2.has('position')).toBeTruthy() }) test('system: define a system', () => { const world = new World() world.system(class {}) - assert(world.systems.systems.length == 1) + expect(world.systems.systems.length == 1).toBeTruthy() }) test('system: define a system with arguments', () => { @@ -363,9 +363,9 @@ test('system: define a system with arguments', () => { } } world.system(velocitySystem, 3500, 'someCanvas', ['textures.png']) - assert(world.systems.systems[0].maxVelocity === 3500) - assert(world.systems.systems[0].canvas === 'someCanvas') - assert(world.systems.systems[0].textures[0] === 'textures.png') + expect(world.systems.systems[0].maxVelocity === 3500).toBeTruthy() + expect(world.systems.systems[0].canvas === 'someCanvas').toBeTruthy() + expect(world.systems.systems[0].textures[0] === 'textures.png').toBeTruthy() }) test('system: define a system with context (no key)', () => { @@ -439,18 +439,18 @@ test('system: system iteration', () => { world.system( class { run(dt, total) { - assert(dt > 0) - assert(total > 0) + expect(dt > 0).toBeTruthy() + expect(total > 0).toBeTruthy() world.each('position', 'velocity', ({ position, velocity }, ent) => { - assert(position) - assert(velocity) + expect(position).toBeTruthy() + expect(velocity).toBeTruthy() position.x += velocity.x position.y += velocity.y - assert(ent) - assert(ent.has('position')) - assert(ent.has('velocity')) - assert(dt > 0) - assert(total > 0) + expect(ent).toBeTruthy() + expect(ent.has('position')).toBeTruthy() + expect(ent.has('velocity')).toBeTruthy() + expect(dt > 0).toBeTruthy() + expect(total > 0).toBeTruthy() }) } } @@ -467,19 +467,31 @@ test('system: system iteration', () => { Object.assign(entB.access('position', {}), { x: 30, y: 40 }) Object.assign(entB.access('velocity', {}), { x: -1, y: 2 }) - assert(entA.get('position').x == 1 && entA.get('position').y == 1) - assert(entB.get('position').x == 30 && entB.get('position').y == 40) + expect( + entA.get('position').x == 1 && entA.get('position').y == 1 + ).toBeTruthy() + expect( + entB.get('position').x == 30 && entB.get('position').y == 40 + ).toBeTruthy() world.run(dt, total) - assert(entA.get('position').x == 2 && entA.get('position').y == 1) - assert(entB.get('position').x == 29 && entB.get('position').y == 42) + expect( + entA.get('position').x == 2 && entA.get('position').y == 1 + ).toBeTruthy() + expect( + entB.get('position').x == 29 && entB.get('position').y == 42 + ).toBeTruthy() total += dt world.run(dt, total) - assert(entA.get('position').x == 3 && entA.get('position').y == 1) - assert(entB.get('position').x == 28 && entB.get('position').y == 44) + expect( + entA.get('position').x == 3 && entA.get('position').y == 1 + ).toBeTruthy() + expect( + entB.get('position').x == 28 && entB.get('position').y == 44 + ).toBeTruthy() }) test('system: system methods', () => { @@ -497,11 +509,11 @@ test('system: system methods', () => { } run() { ++methodsCalled - assert(this.val === 10) + expect(this.val === 10).toBeTruthy() world.each('position', ({ position }) => { position.x = 1 ++methodsCalled - assert(this.val === 10) + expect(this.val === 10).toBeTruthy() }) } } @@ -513,9 +525,9 @@ test('system: system methods', () => { }).toThrow() world.entity().set('position', {}) - assert(methodsCalled == 2) + expect(methodsCalled == 2).toBeTruthy() world.run() - assert(methodsCalled == 4) + expect(methodsCalled == 4).toBeTruthy() }) test('system: system edge cases', () => { @@ -547,18 +559,18 @@ test('system: system edge cases', () => { testEnt0.remove('velocity') return } - assert(position) - assert(velocity) + expect(position).toBeTruthy() + expect(velocity).toBeTruthy() position.x += velocity.x position.y += velocity.y - assert(ent) - assert(ent.has('position')) - assert(ent.has('velocity')) + expect(ent).toBeTruthy() + expect(ent.has('position')).toBeTruthy() + expect(ent.has('velocity')).toBeTruthy() // Make sure the test entities do not show up here - assert(ent.id !== testEnt0.id) - assert(ent.id !== testEnt1.id) - assert(ent.id !== testEnt2.id) + expect(ent.id !== testEnt0.id).toBeTruthy() + expect(ent.id !== testEnt1.id).toBeTruthy() + expect(ent.id !== testEnt2.id).toBeTruthy() }) } } @@ -571,18 +583,30 @@ test('system: system edge cases', () => { Object.assign(entB.access('position', {}), { x: 30, y: 40 }) Object.assign(entB.access('velocity', {}), { x: -1, y: 2 }) - assert(entA.get('position').x == 1 && entA.get('position').y == 1) - assert(entB.get('position').x == 30 && entB.get('position').y == 40) + expect( + entA.get('position').x == 1 && entA.get('position').y == 1 + ).toBeTruthy() + expect( + entB.get('position').x == 30 && entB.get('position').y == 40 + ).toBeTruthy() world.run() - assert(entA.get('position').x == 2 && entA.get('position').y == 1) - assert(entB.get('position').x == 29 && entB.get('position').y == 42) + expect( + entA.get('position').x == 2 && entA.get('position').y == 1 + ).toBeTruthy() + expect( + entB.get('position').x == 29 && entB.get('position').y == 42 + ).toBeTruthy() world.run() - assert(entA.get('position').x == 3 && entA.get('position').y == 1) - assert(entB.get('position').x == 28 && entB.get('position').y == 44) + expect( + entA.get('position').x == 3 && entA.get('position').y == 1 + ).toBeTruthy() + expect( + entB.get('position').x == 28 && entB.get('position').y == 44 + ).toBeTruthy() }) test('system: adding entities to index', () => { @@ -675,16 +699,18 @@ test('system: indexing edge cases', () => { // Ensure initial indexes are good for (let i = 0; i < REPEAT; ++i) { - assert(world.each('noOtherComponents').length === 1) - assert(world.each('sideEffect').length === 0) - assert(world.each('sprite').length === 4) - assert(world.each('velocity').length === 4) - assert(world.each().length === 8) - assert(world.each('position').length === 4) - assert(world.each('position', 'velocity').length === 2) - assert(world.each('position', 'sprite').length === 2) - assert(world.each('position', 'velocity', 'sprite').length === 1) - assert(world.each('velocity', 'sprite').length === 2) + expect(world.each('noOtherComponents').length === 1).toBeTruthy() + expect(world.each('sideEffect').length === 0).toBeTruthy() + expect(world.each('sprite').length === 4).toBeTruthy() + expect(world.each('velocity').length === 4).toBeTruthy() + expect(world.each().length === 8).toBeTruthy() + expect(world.each('position').length === 4).toBeTruthy() + expect(world.each('position', 'velocity').length === 2).toBeTruthy() + expect(world.each('position', 'sprite').length === 2).toBeTruthy() + expect( + world.each('position', 'velocity', 'sprite').length === 1 + ).toBeTruthy() + expect(world.each('velocity', 'sprite').length === 2).toBeTruthy() } // Remove test entities, create more test entities @@ -693,25 +719,25 @@ test('system: indexing edge cases', () => { ++count entity.destroy() }) - assert(count === 4) + expect(count === 4).toBeTruthy() count = 0 world.each('sprite', ({ sprite }, entity) => { ++count entity.destroy() }) - assert(count === 0) + expect(count === 0).toBeTruthy() - assert(g.count === 4) + expect(g.count === 4).toBeTruthy() // Ensure indexes are still good for (let i = 0; i < REPEAT; ++i) { - assert(world.each().length === 4) - assert(world.each('noOtherComponents').length === 1) - assert(world.each('sideEffect').length === 1) - assert(world.each('sprite').length === 0) - assert(world.each('velocity').length === 2) - assert(world.each('position').length === 2) + expect(world.each().length === 4).toBeTruthy() + expect(world.each('noOtherComponents').length === 1).toBeTruthy() + expect(world.each('sideEffect').length === 1).toBeTruthy() + expect(world.each('sprite').length === 0).toBeTruthy() + expect(world.each('velocity').length === 2).toBeTruthy() + expect(world.each('position').length === 2).toBeTruthy() } count = 0 @@ -726,16 +752,16 @@ test('system: indexing edge cases', () => { ++count entity.destroy() }) - assert(count === 0) + expect(count === 0).toBeTruthy() // Ensure indexes are still good for (let i = 0; i < REPEAT; ++i) { - assert(world.each().length === 2) - assert(world.each('noOtherComponents').length === 1) - assert(world.each('sideEffect').length === 0) - assert(world.each('sprite').length === 0) - assert(world.each('velocity').length === 0) - assert(world.each('position').length === 1) + expect(world.each().length === 2).toBeTruthy() + expect(world.each('noOtherComponents').length === 1).toBeTruthy() + expect(world.each('sideEffect').length === 0).toBeTruthy() + expect(world.each('sprite').length === 0).toBeTruthy() + expect(world.each('velocity').length === 0).toBeTruthy() + expect(world.each('position').length === 1).toBeTruthy() } count = 0 @@ -750,18 +776,18 @@ test('system: indexing edge cases', () => { ++count entity.destroy() }) - assert(count === 0) + expect(count === 0).toBeTruthy() world.each('noOtherComponents')[0].destroy() // Ensure new indexes are good for (let i = 0; i < REPEAT; ++i) { - assert(world.each().length === 0) - assert(world.each('noOtherComponents').length === 0) - assert(world.each('sideEffect').length === 0) - assert(world.each('sprite').length === 0) - assert(world.each('velocity').length === 0) - assert(world.each('position').length === 0) + expect(world.each().length === 0).toBeTruthy() + expect(world.each('noOtherComponents').length === 0).toBeTruthy() + expect(world.each('sideEffect').length === 0).toBeTruthy() + expect(world.each('sprite').length === 0).toBeTruthy() + expect(world.each('velocity').length === 0).toBeTruthy() + expect(world.each('position').length === 0).toBeTruthy() } } }) @@ -772,15 +798,15 @@ test('system: system variadic arguments with optional components', () => { world.system( class { constructor(first, second) { - assert(first === 1) - assert(second === 2) + expect(first === 1).toBeTruthy() + expect(second === 2).toBeTruthy() created = true } }, 1, 2 ) - assert(created) + expect(created).toBeTruthy() }) test('system: use the each() method', () => { @@ -790,16 +816,16 @@ test('system: use the each() method', () => { let ent3 = world.entity().set('position:"velocity"', {}) let externalVar = 5 world.each('position', ({ position: pos }, ent) => { - assert(pos) - assert(ent) - assert(ent.has('position')) - assert(externalVar === 5) + expect(pos).toBeTruthy() + expect(ent).toBeTruthy() + expect(ent.has('position')).toBeTruthy() + expect(externalVar === 5).toBeTruthy() }) world.each('position', function ({ position: pos }, ent) { - assert(pos) - assert(ent) - assert(ent.has('position')) - assert(externalVar === 5) + expect(pos).toBeTruthy() + expect(ent).toBeTruthy() + expect(ent.has('position')).toBeTruthy() + expect(externalVar === 5).toBeTruthy() }) // Test hash collisions and escaping @@ -809,10 +835,10 @@ test('system: use the each() method', () => { 'position', '"velocity"', function ({ position: pos, ['"velocity"']: vel }, ent) { - assert(pos) - assert(vel) - assert(ent) - assert(ent.has('position', '"velocity"')) + expect(pos).toBeTruthy() + expect(vel).toBeTruthy() + expect(ent).toBeTruthy() + expect(ent.has('position', '"velocity"')).toBeTruthy() ++count } ) @@ -828,16 +854,16 @@ test('system: use the each() method', () => { // Passing callbacks cause the return value to be undefined results = world.each('position', () => {}) - assert(results === undefined) + expect(results === undefined).toBeTruthy() results = world.each(() => {}) - assert(results === undefined) + expect(results === undefined).toBeTruthy() // Test breaking out of the loop (with components) count = 0 world.each('position', function ({ position }, ent) { - assert(position) - assert(ent) - assert(ent.has('position')) + expect(position).toBeTruthy() + expect(ent).toBeTruthy() + expect(ent.has('position')).toBeTruthy() ++count return false }) @@ -846,8 +872,8 @@ test('system: use the each() method', () => { // Test breaking out of the loop (without components) count = 0 world.each(function (_, ent) { - assert(ent) - assert(ent.valid()) + expect(ent).toBeTruthy() + expect(ent.valid()).toBeTruthy() ++count return false }) @@ -876,11 +902,11 @@ test('system: test indexing with each()', () => { 'position', 'velocity', ({ position: pos, velocity: vel }, ent) => { - assert(ent.has('position', 'velocity')) + expect(ent.has('position', 'velocity')).toBeTruthy() count += pos.val } ) - assert(count == 101) + expect(count == 101).toBeTruthy() count = 0 ent1.remove('position') @@ -890,11 +916,11 @@ test('system: test indexing with each()', () => { 'position', 'velocity', ({ position: pos, velocity: vel }, ent) => { - assert(ent.has('position', 'velocity')) + expect(ent.has('position', 'velocity')).toBeTruthy() count += pos.val } ) - assert(count == 110) + expect(count == 110).toBeTruthy() ent1.remove('sprite') ent2.remove('sprite') @@ -902,29 +928,29 @@ test('system: test indexing with each()', () => { // Query for all entities let test = world.each() - assert(getSize(test) == 3) + expect(getSize(test) == 3).toBeTruthy() let ent4 = world.entity() - assert(getSize(world.each()) == 4) - assert(has(world.each(), ent4)) + expect(getSize(world.each()) == 4).toBeTruthy() + expect(has(world.each(), ent4)).toBeTruthy() ent4.set('velocity') - assert(getSize(world.each()) == 4) - assert(has(world.each(), ent4)) + expect(getSize(world.each()) == 4).toBeTruthy() + expect(has(world.each(), ent4)).toBeTruthy() ent4.remove('velocity') - assert(getSize(world.each()) == 4) - assert(has(world.each(), ent4)) + expect(getSize(world.each()) == 4).toBeTruthy() + expect(has(world.each(), ent4)).toBeTruthy() ent4.destroy() - assert(getSize(world.each()) == 3) - assert(!has(world.each(), ent4)) + expect(getSize(world.each()) == 3).toBeTruthy() + expect(!has(world.each(), ent4)).toBeTruthy() count = 0 world.each(ent => { ++count }) - assert(count == 3) + expect(count == 3).toBeTruthy() count = 0 world.system(