Download src/lib/coding/__tests__/store.test.ts from NAP1320/RotNot: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/lib/coding/__tests__/store.test.ts
- Command line
-
hf download hf://spaces/NAP1320/RotNot/src/lib/coding/__tests__/store.test.ts
-
curl -L -o store.test.ts https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/lib/coding/__tests__/store.test.ts
1.37 kB
| import { resolveProblem, registerProblem } from "../store"; | |
| import { PROBLEM_BANK } from "../bank"; | |
| describe("resolveProblem", () => { | |
| it("resolves a bank problem by its canonical id", () => { | |
| const id = PROBLEM_BANK[0].id; | |
| expect(resolveProblem(id)?.id).toBe(id); | |
| }); | |
| it("resolves an instance id (bankId::uuid) back to the bank problem", () => { | |
| // This is the key serverless property: a fresh lambda instance that never | |
| // saw the registration must still resolve a bank-derived instance id. | |
| const bank = PROBLEM_BANK[0]; | |
| const instanceId = `${bank.id}::00000000-0000-0000-0000-000000000000`; | |
| const resolved = resolveProblem(instanceId); | |
| expect(resolved).not.toBeNull(); | |
| expect(resolved!.type).toBe(bank.type); | |
| expect(resolved!.title).toBe(bank.title); | |
| }); | |
| it("prefers an exactly-registered instance over the bank fallback", () => { | |
| const bank = PROBLEM_BANK.find((p) => p.type === "code-creation")!; | |
| const instanceId = `${bank.id}::deadbeef`; | |
| const custom = { ...bank, id: instanceId, title: "CUSTOM" }; | |
| registerProblem(custom); | |
| expect(resolveProblem(instanceId)?.title).toBe("CUSTOM"); | |
| }); | |
| it("returns null for an unknown id with no bank prefix", () => { | |
| expect(resolveProblem("not-a-real-problem")).toBeNull(); | |
| expect(resolveProblem("not-a-real-problem::abc")).toBeNull(); | |
| }); | |
| }); | |