red: spec parser returns kata steps in order
Asserts loadGame("string-calc") yields the seven step ids in their
authored order. Game type gains a Step[] field; the implementation
still returns [] so the test fails on the diff. Next green will load
the real spec from content/games/<id>/spec.ts.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2 files changed · +19 −1
src/games.test.ts
+13
−0
| @@ -5,3 +5,16 @@ test("loadGame returns a game with the expected id", async () => { | ||
| 5 | 5 | const game = await loadGame("string-calc"); |
| 6 | 6 | expect(game.id).toBe("string-calc"); |
| 7 | 7 | }); |
| 8 | + | |
| 9 | +test("loadGame returns the kata's step ids in order", async () => { | |
| 10 | + const game = await loadGame("string-calc"); | |
| 11 | + expect(game.steps.map((s) => s.id)).toEqual([ | |
| 12 | + "empty", | |
| 13 | + "single-number", | |
| 14 | + "two-numbers", | |
| 15 | + "n-numbers", | |
| 16 | + "newline-separator", | |
| 17 | + "custom-separator", | |
| 18 | + "negatives-throw", | |
| 19 | + ]); | |
| 20 | +}); | |
src/games.ts
+6
−1
| @@ -1,7 +1,12 @@ | ||
| 1 | +export interface Step { | |
| 2 | + id: string; | |
| 3 | +} | |
| 4 | + | |
| 1 | 5 | export interface Game { |
| 2 | 6 | id: string; |
| 7 | + steps: Step[]; | |
| 3 | 8 | } |
| 4 | 9 | |
| 5 | 10 | export async function loadGame(id: string): Promise<Game> { |
| 6 | - return { id }; | |
| 11 | + return { id, steps: [] }; | |
| 7 | 12 | } |