62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
/**
|
|
* commands.test.ts — auto-registration wiring.
|
|
*
|
|
* Asserts that `registerPygieniumCommands` exposes `/pygienium-help`, one
|
|
* `/pygienium-<check>` per registered `CheckDefinition`, plus
|
|
* `all`/`resume`/`status`/`export` — with no index.ts changes.
|
|
*/
|
|
import { describe, expect, it, beforeEach } from "bun:test";
|
|
import {
|
|
clearChecks,
|
|
registerCheck,
|
|
type CheckDefinition,
|
|
} from "../src/checks/registry.js";
|
|
import { registerPygieniumCommands } from "../src/commands.js";
|
|
|
|
function stub(name: string): CheckDefinition {
|
|
return {
|
|
name,
|
|
label: name,
|
|
description: `${name} check`,
|
|
agentName: "scanner",
|
|
phaseId: "scan",
|
|
buildScanTask: () => "scan",
|
|
buildFixTask: () => "fix",
|
|
gate: () => undefined,
|
|
};
|
|
}
|
|
|
|
describe("registerPygieniumCommands", () => {
|
|
beforeEach(() => clearChecks());
|
|
|
|
it("auto-registers one /pygienium-<check> per registered check", () => {
|
|
registerCheck(stub("smoke"));
|
|
registerCheck(stub("comments"));
|
|
const names: string[] = [];
|
|
registerPygieniumCommands((name) => names.push(name));
|
|
expect(names).toContain("pygienium-smoke");
|
|
expect(names).toContain("pygienium-comments");
|
|
expect(names.filter((n) => n === "pygienium-smoke")).toHaveLength(1);
|
|
});
|
|
|
|
it("always registers help/all/resume/status/export", () => {
|
|
const names: string[] = [];
|
|
registerPygieniumCommands((name) => names.push(name));
|
|
expect(names).toContain("pygienium-help");
|
|
expect(names).toContain("pygienium-all");
|
|
expect(names).toContain("pygienium-resume");
|
|
expect(names).toContain("pygienium-status");
|
|
expect(names).toContain("pygienium-export");
|
|
});
|
|
|
|
it("registers with a description matching the check definition", () => {
|
|
registerCheck(stub("smoke"));
|
|
const seen: Record<string, string | undefined> = {};
|
|
registerPygieniumCommands((name, opts) => {
|
|
seen[name] = opts.description;
|
|
});
|
|
expect(seen["pygienium-smoke"]).toBe("smoke check");
|
|
expect(seen["pygienium-help"]).toBeDefined();
|
|
});
|
|
});
|