|
1 | 1 | import { describe, expect, it } from "bun:test"; |
2 | | -import { createComponentId, createEntityId, relation, type EntityId } from "./entity"; |
| 2 | +import { component, createEntityId, relation, type EntityId } from "./entity"; |
3 | 3 | import { World } from "./world"; |
4 | 4 |
|
5 | 5 | describe("World", () => { |
@@ -37,8 +37,8 @@ describe("World", () => { |
37 | 37 | type Position = { x: number; y: number }; |
38 | 38 | type Velocity = { x: number; y: number }; |
39 | 39 |
|
40 | | - const positionComponent = createComponentId<Position>(1); |
41 | | - const velocityComponent = createComponentId<Velocity>(2); |
| 40 | + const positionComponent = component<Position>(); |
| 41 | + const velocityComponent = component<Velocity>(); |
42 | 42 |
|
43 | 43 | it("should add components to entities", () => { |
44 | 44 | const world = new World(); |
@@ -230,8 +230,8 @@ describe("World", () => { |
230 | 230 | type Position = { x: number; y: number }; |
231 | 231 | type Velocity = { x: number; y: number }; |
232 | 232 |
|
233 | | - const positionComponent = createComponentId<Position>(1); |
234 | | - const velocityComponent = createComponentId<Velocity>(2); |
| 233 | + const positionComponent = component<Position>(); |
| 234 | + const velocityComponent = component<Velocity>(); |
235 | 235 |
|
236 | 236 | it("should query entities with specific components", () => { |
237 | 237 | const world = new World(); |
@@ -330,8 +330,8 @@ describe("World", () => { |
330 | 330 | const world = new World(); |
331 | 331 |
|
332 | 332 | // Create component IDs |
333 | | - const positionComponent = createComponentId<{ x: number; y: number }>(1); |
334 | | - const followsComponent = createComponentId<void>(2); |
| 333 | + const positionComponent = component<{ x: number; y: number }>(); |
| 334 | + const followsComponent = component<void>(); |
335 | 335 |
|
336 | 336 | // Create entities |
337 | 337 | const entity1 = world.createEntity(); // This will be followed |
@@ -418,8 +418,8 @@ describe("World", () => { |
418 | 418 | type Position = { x: number; y: number }; |
419 | 419 | type Velocity = { x: number; y: number }; |
420 | 420 |
|
421 | | - const positionComponent = createComponentId<Position>(1); |
422 | | - const velocityComponent = createComponentId<Velocity>(2); |
| 421 | + const positionComponent = component<Position>(); |
| 422 | + const velocityComponent = component<Velocity>(); |
423 | 423 |
|
424 | 424 | it("should trigger component added hooks", () => { |
425 | 425 | const world = new World(); |
@@ -578,7 +578,7 @@ describe("World", () => { |
578 | 578 | describe("Wildcard Relation Hooks", () => { |
579 | 579 | it("should trigger wildcard relation hooks for matching relation components", () => { |
580 | 580 | const world = new World(); |
581 | | - const positionComponent = createComponentId<{ x: number; y: number }>(1); |
| 581 | + const positionComponent = component<{ x: number; y: number }>(); |
582 | 582 | const entity1 = world.createEntity(); |
583 | 583 | const entity2 = world.createEntity(); |
584 | 584 |
|
@@ -622,8 +622,8 @@ describe("World", () => { |
622 | 622 |
|
623 | 623 | it("should not trigger wildcard relation hooks for non-matching components", () => { |
624 | 624 | const world = new World(); |
625 | | - const positionComponent = createComponentId<{ x: number; y: number }>(1); |
626 | | - const velocityComponent = createComponentId<{ vx: number; vy: number }>(2); |
| 625 | + const positionComponent = component<{ x: number; y: number }>(); |
| 626 | + const velocityComponent = component<{ vx: number; vy: number }>(); |
627 | 627 | const entity1 = world.createEntity(); |
628 | 628 | const entity2 = world.createEntity(); |
629 | 629 |
|
|
0 commit comments