Something went wrong. Try again.
Web frontend and supporting services for lance.blue
Something went wrong. Try again.
1.7 kB · 49 lines
JavaScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950/** * Every unit the scenario catalog names resolves in helm's index. * * The catalog is the vendored `.mms` files in the API * (services/api/src/matches/scenarios/) and the library is what helm * publishes. Nothing at runtime checks the join — a name the index does not * key is just a bare hex — so this does, from the sources on both sides, * through the same `candidates` rule the browser resolves with. * * Needs an index: see `unit-index.mjs`. Run with `npm test`. */import { test } from "node:test";import assert from "node:assert/strict";import { readFile, readdir } from "node:fs/promises";import { join } from "node:path";import { fileURLToPath } from "node:url";import { scenarioSources, scenarioUnits } from "./scenario-files.mjs";
const repo = fileURLToPath(new URL("../..", import.meta.url));import { candidates } from "../src/units.ts";import { SKIP, unitIndex } from "./unit-index.mjs";
const units = scenarioUnits( await scenarioSources(repo, readFile, readdir, join),);
test("the catalog parse finds the units", () => { // A refactor that moves the units somewhere this cannot see would make the // file vacuously green; a floor keeps it honest. assert.ok(units.size >= 20, `only found ${units.size} units`); assert.ok(units.has("Wasp WSP-1A"), "a known unit is missing");});
const sprites = await unitIndex();
test( "every catalog unit has a sprite", { skip: sprites ? false : SKIP }, () => { const missing = [...units].filter( (unit) => !candidates(unit).some((name) => sprites.get(name)), ); assert.deepEqual( missing, [], "helm's index has no art for these, so the preview draws a bare hex", ); },);