From 8d678d73ce3de0ac1624a3ef5d48a44d0b394ab2 Mon Sep 17 00:00:00 2001 From: Kamil Krzywda Date: Tue, 29 Sep 2026 02:45:38 +0000 Subject: [PATCH] test: assert events for the remaining action types expand had no event assertion at all; build and mission-complete asserted type/message but not the event's turn. Issue #11 requires every action type to be covered with correct turn/type/message. --- lib/game/missions.test.ts | 1 + lib/game/ship.test.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/game/missions.test.ts b/lib/game/missions.test.ts index 4ac7d6b..91a90cc 100644 --- a/lib/game/missions.test.ts +++ b/lib/game/missions.test.ts @@ -185,6 +185,7 @@ describe('completion', () => { expect(reward.qty).toBe(2) const event = (await db.db.select().from(schema.events)).find((e) => e.type === 'mission' && /complete/i.test(e.message))! + expect(event.turn).toBe(4) // accept (1) + three scans (2–4); completion is written by the third scan expect(event.message).toContain('Scan 3 bodies') }) diff --git a/lib/game/ship.test.ts b/lib/game/ship.test.ts index 40bad31..1c8f374 100644 --- a/lib/game/ship.test.ts +++ b/lib/game/ship.test.ts @@ -111,6 +111,10 @@ describe('expandSystem', () => { expect(systemOf(state, 'HULL').capacity).toBe(BASE_CAPACITY + 1) expect((await db.db.select().from(schema.inventoryItems)).map((i) => [i.name, i.qty])).toEqual([['IRON ORE', 1]]) + const event = (await db.db.select().from(schema.events)).find((e) => e.type === 'expand')! + expect(event.turn).toBe(1) + expect(event.message).toContain('HULL') + await db.db.update(schema.shipSystems).set({ capacity: MAX_CAPACITY }).where(eq(schema.shipSystems.id, hullId)) await expect(expandSystem(db, hullId)).rejects.toMatchObject({ status: 409 }) }) @@ -144,6 +148,7 @@ describe('buildSystem', () => { expect(state.turn).toBe(1) const event = (await db.db.select().from(schema.events)).find((e) => e.type === 'build')! + expect(event.turn).toBe(1) expect(event.message).toContain('WEAPONS') await expect(buildSystem(db, 'WEAPONS')).rejects.toMatchObject({ status: 409 }) // already built