/** * @file Vérifie quelles pages ouvrent le tiroir de toolbox et quelle toolbox il affiche : la toolbox liée * d'un jeu, ou celle choisie dans Sokko TCG, sans liaison. */ import { test } from "node:test"; import assert from "node:assert/strict"; import { CARDS_TOOLBOX_TARGET_ID, getDrawerToolboxId, getRouteToolboxTargetId } from "../website/src/features/toolboxes/toolboxTargets.js"; test("a game page targets its game", () => { assert.equal(getRouteToolboxTargetId("/games/mhwilds"), "mhwilds"); assert.equal(getRouteToolboxTargetId("/games/mhwilds/monsters"), "mhwilds"); }); test("every Sokko TCG section shares the same target", () => { for (const route of ["/cards", "/cards/guild", "/cards/expeditions", "/cards/expeditions/abc", "/cards/admin/catalog"]) { assert.equal(getRouteToolboxTargetId(route), CARDS_TOOLBOX_TARGET_ID, route); } }); test("other pages have no target", () => { for (const route of ["/", "/games", "/toolboxes", "/toolbox/abc", "/library", "/cardsx", "/games/sokko-tcg"]) { assert.equal(getRouteToolboxTargetId(route), "", route); } }); test("a game drawer shows the toolbox linked to the game", () => { const links = { mhwilds: "tbx1" }; assert.equal(getDrawerToolboxId("mhwilds", links, "tbx2", [{ id: "tbx1" }, { id: "tbx2" }]), "tbx1"); assert.equal(getDrawerToolboxId("diablo4", links, "tbx2", [{ id: "tbx1" }, { id: "tbx2" }]), ""); assert.equal(getDrawerToolboxId("", links, "tbx2", [{ id: "tbx1" }, { id: "tbx2" }]), ""); }); test("the Sokko TCG drawer shows the chosen toolbox, linked to a game or not, until it is deleted", () => { const links = { mhwilds: "tbx1" }; const toolboxes = [{ id: "tbx1" }, { id: "tbx2" }]; assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "tbx1", toolboxes), "tbx1"); assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "tbx2", toolboxes), "tbx2"); assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "", toolboxes), ""); assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "deleted", toolboxes), ""); });