Skip to content

Commit e26478b

Browse files
committed
🧪 core: add failing test for issue 115
1 parent 69e2f47 commit e26478b

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

packages/core/tests/query-modifiers.test.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
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';
33
import { $internal } from '../src/common';
44
import { createAdded } from '../src/query/modifiers/added';
55
import { createChanged } from '../src/query/modifiers/changed';
66
import { Not } from '../src/query/modifiers/not';
7-
import { Or } from '../src/query/modifiers/or';
87
import { createRemoved } from '../src/query/modifiers/removed';
9-
import { IsExcluded } from '../src/query/query';
108
import { getStore, trait } from '../src/trait/trait';
119

1210
const Position = trait({ x: 0, y: 0 });
13-
const Name = trait({ name: 'name' });
1411
const IsActive = trait();
1512
const Foo = trait({});
1613
const Bar = trait({});
@@ -476,4 +473,25 @@ describe('Query modifiers', () => {
476473
entity.changed(Foo);
477474
expect(world.queryFirst(Foo, Changed(Bar))).toBeUndefined();
478475
});
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+
});
479497
});

0 commit comments

Comments
 (0)