Files
systemic-game-design-course/course/01-handles/tests/ts/test_01.test.ts
T
2026-10-29 00:17:31 +01:00

50 lines
1.4 KiB
TypeScript

// Module 1: Handles and order of play. Each test matches a heading in scenarios.md.
import { expect, test } from "vitest";
import { newGame } from "../src/harness";
test("test_01_ids_stable_and_order_increases", () => {
const g = newGame();
const a = g.summon("Test Filler", 0);
const orderA = g.orderOfPlay(a);
const b = g.summon("Test Filler", 0);
expect(a).not.toBe(b);
expect(g.orderOfPlay(a)).toBeLessThan(g.orderOfPlay(b));
expect(g.orderOfPlay(a)).toBe(orderA);
expect(g.nameOf(a)).toBe("Test Filler");
expect(g.zoneOf(a)).toBe("board");
expect(g.board(0)).toEqual([a, b]);
});
test("test_01_zones", () => {
const g = newGame();
const d = g.addToDeck("Test Filler", 0);
const h = g.addToHand("Test Filler", 0);
const s = g.summon("Test Filler", 0);
expect(g.zoneOf(d)).toBe("deck");
expect(g.zoneOf(h)).toBe("hand");
expect(g.zoneOf(s)).toBe("board");
expect(g.hand(0)).toEqual([h]);
expect(g.board(0)).toEqual([s]);
});
test("test_01_board_query_per_player", () => {
const g = newGame();
const a0 = g.summon("Test Filler", 0);
const a1 = g.summon("Test Filler", 1);
const b0 = g.summon("Test Filler", 0);
expect(g.board(0)).toEqual([a0, b0]);
expect(g.board(1)).toEqual([a1]);
});
test("test_01_names", () => {
const g = newGame();
const a = g.summon("Test Filler", 0);
const h = g.addToHand("Test Filler", 1);
expect(g.nameOf(a)).toBe("Test Filler");
expect(g.nameOf(h)).toBe("Test Filler");
});