Skip to content

Commit 7780fef

Browse files
committed
Merge branch 'main' of https://github.com/pmndrs/koota
2 parents 5ebd249 + 50aa907 commit 7780fef

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/core/src/world/world.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ export class World {
165165

166166
if (typeof args[0] === 'string') {
167167
const query = ctx.queriesHashMap.get(args[0]);
168-
if (!query) return [];
169-
return query.run(this);
168+
// TODO: Query results need to be refactored so query.run() returns it and we can create emtpy ones
169+
if (!query) return createQueryResult(new Query(this, []), this, []);
170+
return createQueryResult(query, this, query.parameters);
170171
} else {
171172
const params = args as QueryParameter[];
172173
const hash = createQueryHash(params);

packages/core/tests/query.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,17 @@ describe('Query', () => {
203203

204204
let entities = world.query(key);
205205

206-
expect(entities).toEqual([entityA]);
206+
expect(entities).toContain(entityA);
207+
208+
// Check that a query result is returned.
209+
expect(entities.updateEach).toBeDefined();
207210

208211
// Test caching before a world is created.
209212
const world2 = createWorld();
210213
const entityC = world2.spawn(Position, Name, IsActive);
211214
const query2 = world2.query(key);
212215

213-
expect(query2).toEqual([entityC]);
216+
expect(query2).toContain(entityC);
214217
});
215218

216219
it('should exclude entities with IsExcluded', () => {

0 commit comments

Comments
 (0)