Skip to content

Commit b2199b0

Browse files
committed
test(cli): type reparse raw args setup
1 parent 4b42087 commit b2199b0

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/cli/program/action-reparse.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ vi.mock("./helpers.js", () => ({
1616
resolveCommandOptionArgs: resolveCommandOptionArgsMock,
1717
}));
1818

19+
function setRawArgs(command: Command, rawArgs: string[]): void {
20+
(command as Command & { rawArgs: string[] }).rawArgs = rawArgs;
21+
}
22+
1923
describe("reparseProgramFromActionArgs", () => {
2024
beforeEach(() => {
2125
vi.clearAllMocks();
@@ -26,7 +30,7 @@ describe("reparseProgramFromActionArgs", () => {
2630

2731
it("uses action command name + args as fallback argv", async () => {
2832
const program = new Command().name("openclaw");
29-
program.rawArgs = ["node", "openclaw", "status", "--json"];
33+
setRawArgs(program, ["node", "openclaw", "status", "--json"]);
3034
const parseAsync = vi.spyOn(program, "parseAsync").mockResolvedValue(program);
3135
const actionCommand = {
3236
name: () => "status",
@@ -46,7 +50,7 @@ describe("reparseProgramFromActionArgs", () => {
4650

4751
it("falls back to action args without command name when action has no name", async () => {
4852
const program = new Command().name("openclaw");
49-
program.rawArgs = ["node", "openclaw"];
53+
setRawArgs(program, ["node", "openclaw"]);
5054
const parseAsync = vi.spyOn(program, "parseAsync").mockResolvedValue(program);
5155
const actionCommand = {
5256
name: () => "",
@@ -87,7 +91,7 @@ describe("reparseProgramFromActionArgs", () => {
8791

8892
it("uses root raw args and reparses the root for nested lazy commands", async () => {
8993
const root = new Command().name("openclaw");
90-
root.rawArgs = ["node", "openclaw", "workspaces", "audit", "export", "--since", "1"];
94+
setRawArgs(root, ["node", "openclaw", "workspaces", "audit", "export", "--since", "1"]);
9195
const workspaces = root.command("workspaces");
9296
const audit = workspaces.command("audit");
9397
const exportCommand = audit.command("export");

0 commit comments

Comments
 (0)