import { describe, expect, it } from "vitest"; import { generateTableName } from "@/lib/minigames/tableNames"; import { MAX_TABLE_NAME_LENGTH } from "@/lib/minigames/blackjack"; /** * Default table titles: created tables start with a human codename * ("Amber Falcon") instead of the raw table UUID. Both card game * registries share this generator. */ describe("generateTableName", () => { it("produces a two-word title from the word lists", () => { const name = generateTableName(() => 0); expect(name).toBe("Amber Ace"); }); it("varies with the rng but stays reproducible per seed", () => { const a = generateTableName(() => 0.999); const b = generateTableName(() => 0.999); const c = generateTableName(() => 0.5); expect(a).toBe(b); expect(c).not.toBe("Amber Ace"); expect(a.split(" ")).toHaveLength(2); expect(c.split(" ")).toHaveLength(2); }); it("stays within the table-name length limit and needs no trimming", () => { for (let seed = 0; seed < 40; seed += 1) { const name = generateTableName(); expect(name.length).toBeGreaterThan(0); expect(name.length).toBeLessThanOrEqual(MAX_TABLE_NAME_LENGTH); expect(name).toBe(name.trim()); } }); });