dbb7885ffd
CI / check (pull_request) Failing after 1m39s
- Auto-fix: import sorting, formatting (17 files) - Unsafe auto-fix: unused vars, template literals (7 files) - Manual: nursery/noConsole → suspicious/noConsole suppression - Manual: suppress noExcessiveCognitiveComplexity for cmdThreadResume and parseWorkflowPayload - Manual: remove unused destructured vars in current-role tests Closes #48
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { parseArgv } from "../src/run.js";
|
|
|
|
describe("parseArgv", () => {
|
|
let exitSpy: ReturnType<typeof vi.spyOn>;
|
|
let _stderrSpy: ReturnType<typeof vi.spyOn>;
|
|
|
|
beforeEach(() => {
|
|
exitSpy = vi.spyOn(process, "exit").mockImplementation((() => {
|
|
throw new Error("process.exit");
|
|
}) as never);
|
|
_stderrSpy = vi.spyOn(process.stderr, "write").mockImplementation((() => true) as never);
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("returns threadId, role, prompt for valid argv", () => {
|
|
const result = parseArgv([
|
|
"node",
|
|
"script",
|
|
"--thread",
|
|
"abc123",
|
|
"--role",
|
|
"developer",
|
|
"--prompt",
|
|
"do stuff",
|
|
]);
|
|
expect(result).toEqual({ threadId: "abc123", role: "developer", prompt: "do stuff" });
|
|
});
|
|
|
|
it("exits when --thread is missing", () => {
|
|
expect(() => parseArgv(["node", "script", "--role", "dev", "--prompt", "x"])).toThrow(
|
|
"process.exit",
|
|
);
|
|
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
});
|
|
|
|
it("exits when --role is missing", () => {
|
|
expect(() => parseArgv(["node", "script", "--thread", "t1", "--prompt", "x"])).toThrow(
|
|
"process.exit",
|
|
);
|
|
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
});
|
|
|
|
it("exits when --prompt is missing", () => {
|
|
expect(() => parseArgv(["node", "script", "--thread", "t1", "--role", "dev"])).toThrow(
|
|
"process.exit",
|
|
);
|
|
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
});
|
|
});
|