@@ -343,4 +343,58 @@ describe('Query Integration Tests', () => {
343
343
expect ( ents . length ) . toBe ( 1 ) ;
344
344
expect ( ents ) . toBeInstanceOf ( Uint32Array ) ;
345
345
} ) ;
346
+
347
+ it ( 'should not alter query results when removing entities' , ( ) => {
348
+ const world = createWorld ( ) ;
349
+ const TestComponent = defineComponent ( { value : Types . f32 } ) ;
350
+
351
+ for ( let i = 0 ; i < 10 ; i += 1 ) {
352
+ const eid = addEntity ( world ) ;
353
+ addComponent ( world , TestComponent , eid ) ;
354
+ }
355
+
356
+ const results = query ( world , [ TestComponent ] ) ;
357
+ const length = results . length ;
358
+ for ( const eid of results ) {
359
+ removeEntity ( world , eid ) ;
360
+ }
361
+
362
+ expect ( length ) . toBe ( results . length ) ;
363
+ } ) ;
364
+
365
+ it ( 'should not alter query results when removing a query component' , ( ) => {
366
+ const world = createWorld ( ) ;
367
+ const TestComponent = defineComponent ( { value : Types . f32 } ) ;
368
+
369
+ for ( let i = 0 ; i < 10 ; i += 1 ) {
370
+ const eid = addEntity ( world ) ;
371
+ addComponent ( world , TestComponent , eid ) ;
372
+ }
373
+
374
+ const results = query ( world , [ TestComponent ] ) ;
375
+ const length = results . length ;
376
+ for ( const eid of results ) {
377
+ removeComponent ( world , TestComponent , eid ) ;
378
+ }
379
+
380
+ expect ( length ) . toBe ( results . length ) ;
381
+ } ) ;
382
+
383
+ it ( 'should not alter query results when buffered' , ( ) => {
384
+ const world = enableBufferedQueries ( createWorld ( ) ) ;
385
+ const TestComponent = defineComponent ( { value : Types . f32 } ) ;
386
+
387
+ for ( let i = 0 ; i < 10 ; i += 1 ) {
388
+ const eid = addEntity ( world ) ;
389
+ addComponent ( world , TestComponent , eid ) ;
390
+ }
391
+
392
+ const results = query ( world , [ TestComponent ] ) ;
393
+ const length = results . length ;
394
+ for ( const eid of results ) {
395
+ removeEntity ( world , eid ) ;
396
+ }
397
+
398
+ expect ( length ) . toBe ( results . length ) ;
399
+ } ) ;
346
400
} ) ;
0 commit comments