sokko-g/tests/toolbox-targets.test.mjs
Shinuwa 22b397ebfa Document Sokko G's architecture and folders, and move JavaScript file headers to JSDoc @file blocks
Add ARCHITECTURE.md (layers, flows, folder map, glossary), CONTRIBUTING.md
(setup and step-by-step recipes) and a README in each main folder, with an
index of docs/. Convert the 511 JavaScript headers from "// Rôle :" lines to
JSDoc @file blocks, define a three-level header template in website/AGENTS.md
and check the header in tests/file-headers.test.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 09:42:13 +01:00

41 lines
2 KiB
JavaScript

/**
* @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), "");
});