Files
systemic-game-design-course/tools/test/verify-references.test.mjs
T
Lucas WintherandClaude Opus 5.5 e04dc1a11f feat: module 05 assemble
Cards become JSON data in course/cards (one file per card, validated
against card.schema.json and the catalog); the M5 references load them
via registerCards and interpret effects, replacing content closures.
Adds assemble(base, donor, half), the assemble/buffHand effects with an
injected chooser, Fleshshape as the data-only Expansion Drop, and stages
course/cards in verify-references and start-module.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 03:17:21 +01:00

69 lines
2.7 KiB
JavaScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { join } from "node:path";
import { run, fixtures } from "./helpers.mjs";
import { planVerification } from "../verify-references.mjs";
import { moduleDirs } from "../lib.mjs";
const root = join(fixtures, "course");
test("verify_plan_skips_modules_without_reference", () => {
process.env.COURSE_ROOT = root;
const plan = planVerification(moduleDirs(), 3);
assert.deepEqual(plan.map((p) => p.num), ["01", "02", "03"]);
assert.deepEqual(plan[2].testModules.map((m) => m.num), ["01", "02", "03"]);
assert.deepEqual(plan[2].langs, ["rust", "ts"]);
});
test("verify_runs_with_copied_reference_and_tests", () => {
const r = run("verify-references.mjs", ["02"], {
COURSE_ROOT: root,
VERIFY_CMD_RUST: "test -f tests/m01.rs && test -f Cargo.toml && ! test -f tests/m03.rs",
VERIFY_CMD_TS: "test -f tests/m01.test.ts && test -f package.json",
});
assert.equal(r.code, 0, r.out);
assert.match(r.out, /01.*ok/s);
assert.match(r.out, /02.*ok/s);
});
test("verify_reports_failure", () => {
const r = run("verify-references.mjs", ["01"], {
COURSE_ROOT: root,
VERIFY_CMD_RUST: "false",
VERIFY_CMD_TS: "true",
});
assert.equal(r.code, 1);
assert.match(r.out, /FAIL/);
});
test("verify_stage_copies_all_earlier_module_tests", async () => {
process.env.COURSE_ROOT = root;
const { planVerification, stage } = await import("../verify-references.mjs");
const { existsSync } = await import("node:fs");
const plan = planVerification(moduleDirs(), 3)[2];
const dir = stage(plan, "rust");
for (const f of ["m01.rs", "m02.rs", "m03.rs"]) assert.ok(existsSync(join(dir, "tests", f)));
assert.ok(existsSync(join(dir, "Cargo.toml")));
});
test("verify_stage_copies_course_cards", async () => {
// From Module 5 the references load card data from <crate or package root>/cards.
process.env.COURSE_ROOT = root;
const { planVerification, stage } = await import("../verify-references.mjs");
const { existsSync } = await import("node:fs");
for (const lang of ["rust", "ts"]) {
const dir = stage(planVerification(moduleDirs(), 1)[0], lang);
assert.ok(existsSync(join(dir, "cards", "test-fixture.json")), lang);
}
});
test("verify_ts_default_installs_dependencies_first", async () => {
// A staged reference has no node_modules; a bare `npx vitest` fetches the
// latest vitest, which cannot load the reference's vitest.config.ts.
const { commandFor } = await import("../verify-references.mjs");
const cmd = commandFor("ts", {});
assert.match(cmd, /^npm (ci|install)\b.*&& npx vitest run$/);
assert.equal(commandFor("ts", { VERIFY_CMD_TS: "true" }), "true");
assert.equal(commandFor("rust", {}), "cargo test");
});