// The board a project was scaffolded from: the case whose video hand-off names it. import assert from "node:assert/strict"; import test from "node:test"; import { boardOfArticle, boardOfProject } from "./board.mjs"; test("a project's board is the case whose video hand-off names it, the newest when two do", () => { const cases = [ { id: "ferret", title: "Ferret sanctuary", handoffs: [{ to: "article", href: "/articles/ferret?tab=iterations", at: "2026-10-14T09:00:00Z" }] }, { id: "permit", title: "The permit", handoffs: [{ to: "video", href: "/projects/the-permit", at: "2026-10-14T10:00:00Z" }] }, { id: "permit-2", title: "The permit, again", handoffs: [{ to: "video", href: "/projects/the-permit", at: "2026-10-14T11:00:00Z" }] }, ]; assert.deepEqual(boardOfProject("the-permit", cases), { id: "permit-2", title: "The permit, again", at: "2026-10-14T11:00:00Z" }); assert.equal(boardOfProject("ferret", cases), null, "an article hand-off is not a video's board"); assert.equal(boardOfProject("reports/x", []), null); // Encoded segments and a query on the href still match. assert.equal(boardOfProject("a b", [{ id: "c", title: "C", handoffs: [{ to: "video", href: "/projects/a%20b?tab=cut" }] }])?.id, "c"); }); test("an article's board is the case whose ARTICLE hand-off names its page", () => { const cases = [ { id: "ferret", title: "Ferret sanctuary", handoffs: [{ to: "article", href: "/articles/ferret", at: "2026-10-14T09:00:00Z" }] }, { id: "permit", title: "The permit", handoffs: [{ to: "video", href: "/articles/ferret", at: "2026-10-14T10:00:00Z" }] }, ]; assert.deepEqual(boardOfArticle("/articles/ferret", cases), { id: "ferret", title: "Ferret sanctuary", at: "2026-10-14T09:00:00Z" }); assert.equal(boardOfArticle("/articles/other", cases), null); assert.equal(boardOfProject("ferret", cases), null); });