|
1 |
| -import { beforeEach, describe, expect, it, vi } from 'vitest'; |
2 |
| -import { cacheQuery, createWorld } from '../src'; |
| 1 | +import { beforeEach, describe, expect, it } from 'vitest'; |
| 2 | +import { createWorld } from '../src'; |
3 | 3 | import { $internal } from '../src/common';
|
4 | 4 | import { createAdded } from '../src/query/modifiers/added';
|
5 | 5 | import { createChanged } from '../src/query/modifiers/changed';
|
6 | 6 | import { Not } from '../src/query/modifiers/not';
|
7 |
| -import { Or } from '../src/query/modifiers/or'; |
8 | 7 | import { createRemoved } from '../src/query/modifiers/removed';
|
9 |
| -import { IsExcluded } from '../src/query/query'; |
10 | 8 | import { getStore, trait } from '../src/trait/trait';
|
11 | 9 |
|
12 | 10 | const Position = trait({ x: 0, y: 0 });
|
13 |
| -const Name = trait({ name: 'name' }); |
14 | 11 | const IsActive = trait();
|
15 | 12 | const Foo = trait({});
|
16 | 13 | const Bar = trait({});
|
@@ -476,4 +473,25 @@ describe('Query modifiers', () => {
|
476 | 473 | entity.changed(Foo);
|
477 | 474 | expect(world.queryFirst(Foo, Changed(Bar))).toBeUndefined();
|
478 | 475 | });
|
| 476 | + |
| 477 | + // @see https://github.com/pmndrs/koota/issues/115 |
| 478 | + it.fails('should not trigger Changed query when removing a different trait', () => { |
| 479 | + const Changed = createChanged(); |
| 480 | + const entity = world.spawn(Position); |
| 481 | + |
| 482 | + // Initial state - no changes |
| 483 | + expect(world.queryFirst(Changed(Position), Not(Foo))).toBeUndefined(); |
| 484 | + |
| 485 | + // Change Position |
| 486 | + entity.changed(Position); |
| 487 | + expect(world.queryFirst(Changed(Position), Not(Foo))).toBe(entity); |
| 488 | + |
| 489 | + // Query again - should be empty |
| 490 | + expect(world.queryFirst(Changed(Position), Not(Foo))).toBeUndefined(); |
| 491 | + |
| 492 | + // Add and remove Foo - should be empty |
| 493 | + entity.add(Foo); |
| 494 | + entity.remove(Foo); |
| 495 | + expect(world.queryFirst(Changed(Position), Not(Foo))).toBeUndefined(); |
| 496 | + }); |
479 | 497 | });
|
0 commit comments