Something went wrong. Try again.
Fork of backnotprop/plannotator with reduced surface area
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162import { describe, expect, test } from "bun:test";import { formatInteractiveNoArgClarification, formatTopLevelHelp, formatVersion, isInteractiveNoArgInvocation, isTopLevelHelpInvocation, isVersionInvocation,} from "./cli";
describe("CLI top-level help", () => { test("recognizes top-level --help", () => { expect(isTopLevelHelpInvocation(["--help"])).toBe(true); expect(isTopLevelHelpInvocation([])).toBe(false); expect(isTopLevelHelpInvocation(["review", "--help"])).toBe(false); });
test("renders concise top-level usage", () => { const output = formatTopLevelHelp();
expect(output).toContain("plannotator --help"); expect(output).toContain("plannotator --version, -v"); expect(output).toContain("plannotator [--browser <name>]"); expect(output).toContain("plannotator review [--git] [PR_URL]"); expect(output).toContain("plannotator annotate <file.md | file.html | https://... | folder/>"); expect(output).toContain("running 'plannotator' without arguments is for hook integration"); });});
describe("CLI --version", () => { test("recognizes --version and -v", () => { expect(isVersionInvocation(["--version"])).toBe(true); expect(isVersionInvocation(["-v"])).toBe(true); expect(isVersionInvocation([])).toBe(false); expect(isVersionInvocation(["review"])).toBe(false); });
test("formats version string", () => { const output = formatVersion(); expect(output).toStartWith("plannotator "); });});
describe("interactive no-arg invocation", () => { test("detects bare interactive invocation only when stdin is a TTY", () => { expect(isInteractiveNoArgInvocation([], true)).toBe(true); expect(isInteractiveNoArgInvocation([], false)).toBe(false); expect(isInteractiveNoArgInvocation([], undefined)).toBe(false); expect(isInteractiveNoArgInvocation(["review"], true)).toBe(false); });
test("renders clarification for interactive users", () => { const output = formatInteractiveNoArgClarification();
expect(output).toContain("usually launched automatically by Claude Code hooks"); expect(output).toContain("It expects hook JSON on stdin."); expect(output).toContain("plannotator review"); expect(output).toContain("plannotator sessions"); expect(output).toContain("Run 'plannotator --help' for top-level usage."); });});