syntaxai/tdd.md · main · src / a31_games.test.ts

a31_games.test.ts 27 lines · 734 bytes raw
import { test, expect } from "bun:test";
import { loadGame } from "./a31_games.ts";

test("loadGame returns a game with the expected id", async () => {
  const game = await loadGame("string-calc");
  expect(game.id).toBe("string-calc");
});

test("loadGame returns the kata's step ids in order", async () => {
  const game = await loadGame("string-calc");
  expect(game.steps.map((s) => s.id)).toEqual([
    "empty",
    "single-number",
    "two-numbers",
    "n-numbers",
    "newline-separator",
    "custom-separator",
    "negatives-throw",
  ]);
});

test("loadGame throws a clear error for an unknown game", async () => {
  await expect(loadGame("does-not-exist")).rejects.toThrow(
    /unknown game: does-not-exist/,
  );
});