This commit is contained in:
latypov committed 2026-11-23 23:55:37 +07:00
commit 2ca7a264b3
53 files changed
+7113

No files matched your search

+69
View File
@@ -0,0 +1,69 @@
import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { airfield } from "../game/static/airfield.js";
import { cardFace } from "../game/static/cards.js";
const catalog = JSON.parse(
readFileSync(new URL("../game/catalog.json", import.meta.url)),
);
const empty = {
geometry: catalog.board,
markers: {},
selected: "",
pickable: new Set(),
destinations: new Set(),
weather: null,
};
test("A labelled vector face exists for each card in the rules catalog", () => {
for (const code of Object.keys(catalog.cards)) {
const card = cardFace(code, 0, true, true);
assert.ok(card.includes('data-code="' + code + '"'));
for (const cls of ["fc-title", "fc-en", "fc-effect"])
assert.match(card, new RegExp('class="' + cls + '"[^>]*>[^<]+<'));
assert.match(card, /<svg[^>]*>.*<path/s);
assert.match(card, /aria-pressed="true"/);
assert.doesNotMatch(card, /undefined/);
assert.doesNotMatch(cardFace(code, 0, false, false), /data-act=/);
}
});
test("Positions are unique and all six positions on each runway have a marker", () => {
const svg = airfield(empty);
const ids = Array.from(svg.matchAll(/data-position="([^"]+)"/g), (m) => m[1]);
assert.equal(ids.length, new Set(ids).size);
const b = catalog.board;
assert.equal(
ids.length,
b.ab_stands +
b.b_stands +
2 * b.ac_stands +
b.vip_lanes * 2 +
b.runways.length * b.queue_capacity,
);
for (const lane of b.runways)
for (let i = 0; i < b.queue_capacity; i++)
assert.ok(ids.includes("D:" + lane + ":" + i));
});
test("Only supplied targets are interactive; the preview is read-only", () => {
assert.doesNotMatch(airfield(empty), /data-act=/);
const svg = airfield({
...empty,
markers: {
"A:B2": {
key: "blue-1",
caption: "С1",
size: 3,
color: "#345",
name: "Синяя",
},
},
pickable: new Set(["blue-1"]),
destinations: new Set(["B:B3"]),
selected: "blue-1",
});
assert.match(svg, /data-act="pick" data-val="blue-1"/);
assert.match(svg, /data-act="mapdest" data-val="B:B3"/);
assert.equal([...svg.matchAll(/data-act=/g)].length, 2);
assert.match(svg, /href="#jet3"/);
});