Files
systemic-game-design-course/tools/test/expansion-check.test.mjs
T
Lucas WintherandClaude Opus 5.5 ad0701395d fix(tools): stage course cards from M5, audit noun words without flagging identifiers, Node<24.2 main guard, rename-proof expansion-check, safe check-links
- cardDirs: course/cards only from Module 5 (spec 6.2a); fixture modules 04/05 and tests
- coupling-audit: noun words match as UPPERCASE, PascalCase or a whole string literal;
  lowercase identifiers like key/flag pass; card names keep every variant
- isMain() argv guard replaces import.meta.main in coupling-audit and verify-references;
  engines.node >=22
- expansion-check: git diff --no-renames so moving engine code into content fails
- start-module and other tools: clear error when .course.json is missing
- check-links: malformed URLs reported as invalid URL instead of throwing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 19:06:56 +01:00

47 lines
1.6 KiB
JavaScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { run, copyFixture, git } from "./helpers.mjs";
function repo() {
const ws = copyFixture("ws-content-only");
git(ws, "init", "-q");
git(ws, "add", "-A");
git(ws, "commit", "-qm", "base");
git(ws, "tag", "base");
return ws;
}
test("expansion_check_rejects_engine_edit", () => {
const ws = repo();
writeFileSync(join(ws, "src/engine/core.rs"), "fn changed() {}\n");
const r = run("expansion-check.mjs", [ws, "base"]);
assert.equal(r.code, 1);
assert.match(r.out, /src\/engine\/core\.rs/);
});
test("expansion_check_rejects_new_engine_file", () => {
const ws = repo();
writeFileSync(join(ws, "src/engine/new.rs"), "fn n() {}\n");
assert.equal(run("expansion-check.mjs", [ws, "base"]).code, 1);
});
test("expansion_check_accepts_content_only", () => {
const ws = repo();
writeFileSync(join(ws, "src/content/cards.rs"), "// new card\n");
writeFileSync(join(ws, "src/content/more.rs"), "// untracked\n");
const r = run("expansion-check.mjs", [ws, "base"]);
assert.equal(r.code, 0, r.out);
});
test("expansion_check_rejects_engine_file_moved_into_content", () => {
// A rename shows only its new path under `git diff --name-only`; --no-renames lists
// the deleted engine path too.
const ws = repo();
git(ws, "mv", "src/engine/core.rs", "src/content/core.rs");
const r = run("expansion-check.mjs", [ws, "base"]);
assert.equal(r.code, 1, r.out);
assert.match(r.out, /src\/engine\/core\.rs/);
});