Files
truthmark/tests/cli/help.test.ts
T
e9cd67f0b5 refactor: remove semantic repository index (#17)
* docs: replace legacy truth path references

* feat: fold contextpack into workflow status

* refactor: remove semantic repository index

* fix: remove vulnerable frontmatter dependency

* feat: broaden truth sync write authorization

* test: restore workflow state regression coverage

---------

Co-authored-by: MerlinH <merlinh221@gmail.com>
2026-06-16 11:03:04 +10:00

81 lines
2.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { runCli } from "../helpers/run-cli.js";
const forbiddenCommands = [
"packet",
"review",
"scan",
"doctor",
"build",
"realize",
];
describe("truthmark CLI", () => {
it("lists config, init, and check in top-level help", async () => {
const result = await runCli(["--help"]);
expect(result.exitCode).toBe(0);
expect(result.stdout).toContain("config");
expect(result.stdout).toContain("init");
expect(result.stdout).toContain("check");
expect(result.stdout).toContain("index");
expect(result.stdout).toContain("impact");
expect(result.stdout).not.toContain("context");
for (const command of forbiddenCommands) {
expect(result.stdout).not.toContain(command);
}
});
it("shows init help", async () => {
const result = await runCli(["init", "--help"]);
expect(result.exitCode).toBe(0);
expect(result.stdout).toContain("Usage: truthmark init");
expect(result.stdout).toContain("--json");
});
it("shows config help", async () => {
const result = await runCli(["config", "--help"]);
expect(result.exitCode).toBe(0);
expect(result.stdout).toContain("Usage: truthmark config");
expect(result.stdout).toContain("--json");
expect(result.stdout).toContain("--stdout");
expect(result.stdout).toContain("--force");
});
it("shows check help", async () => {
const result = await runCli(["check", "--help"]);
expect(result.exitCode).toBe(0);
expect(result.stdout).toContain("Usage: truthmark check");
expect(result.stdout).toContain("--json");
expect(result.stdout).not.toContain("--workflow");
});
it("returns valid JSON for check", async () => {
const result = await runCli(["check", "--json"]);
expect(result.exitCode).toBe(0);
const payload = JSON.parse(result.stdout) as {
command: string;
summary: string;
diagnostics: unknown[];
data?: {
scorecard?: {
schemaVersion?: string;
};
};
};
expect(payload.command).toBe("check");
expect(typeof payload.summary).toBe("string");
expect(payload.summary.length).toBeGreaterThan(0);
expect(Array.isArray(payload.diagnostics)).toBe(true);
expect(payload.data?.scorecard?.schemaVersion).toBe("truthmark-scorecard/v0");
});
});