1
0
Fork 0
polaris-task-force/tests/int/table-names.int.spec.ts
Z8MB1E c5defa9e70 feat(poker): engine upgrades, named tables, and stat extensions
Poker lib layer: engine, tables, stats, hand setup, shared table names, with engine tests.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-09-14 15:37:19 -04:00

35 lines
1.2 KiB
TypeScript

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());
}
});
});