Initial crossword addition and arcade redesign
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m41s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m41s
This commit is contained in:
parent
611a585757
commit
5bec95fb30
32 changed files with 1635 additions and 56 deletions
26
src/lib/arcade/crosswordEngine.test.ts
Normal file
26
src/lib/arcade/crosswordEngine.test.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { generateCrosswordLayout } from "@/lib/arcade/crosswordEngine";
|
||||
import { crosswordTestPack } from "@/lib/arcade/crosswordTestData";
|
||||
|
||||
describe("Crossword grid engine", () => {
|
||||
it("is deterministic and respects the selected target", () => {
|
||||
const pack = crosswordTestPack();
|
||||
const first = generateCrosswordLayout(pack, "mini", "same-seed");
|
||||
const second = generateCrosswordLayout(pack, "mini", "same-seed");
|
||||
expect(second).toEqual(first);
|
||||
expect(first.entries).toHaveLength(15);
|
||||
expect(first.entries.length).toBeLessThanOrEqual(first.targetCount);
|
||||
expect(first.entries.length + first.omittedEntries.length).toBe(80);
|
||||
});
|
||||
|
||||
it("creates matching cells, shared intersections, and sequential clue numbers", () => {
|
||||
const layout = generateCrosswordLayout(crosswordTestPack(), "standard", "grid-rules");
|
||||
const cellByKey = new Map(layout.cells.map((cell) => [cell.key, cell]));
|
||||
expect(layout.entries.length).toBeGreaterThanOrEqual(15);
|
||||
expect(layout.cells.some((cell) => cell.entryIds.length > 1)).toBe(true);
|
||||
for (const entry of layout.entries) {
|
||||
expect(entry.cellKeys.map((key, index) => cellByKey.get(key)?.answer === entry.answer[index]).every(Boolean)).toBe(true);
|
||||
expect(entry.number).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue