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.
This commit is contained in:
@@ -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')
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user