test(cli): add windows-argv unit tests

This commit is contained in:
kumarabhirup 2026-03-02 18:31:00 -08:00
parent 91e3742be7
commit e5aa1ac311
No known key found for this signature in database
GPG Key ID: DB7CA2289CAB0167

View File

@ -0,0 +1,38 @@
import { describe, expect, it } from "vitest";
import { normalizeWindowsArgv } from "./windows-argv.js";
describe("normalizeWindowsArgv", () => {
it("returns argv unchanged on non-windows platforms", () => {
const argv = ["node", "ironclaw", "status"];
expect(
normalizeWindowsArgv(argv, {
platform: "darwin",
}),
).toEqual(argv);
});
it("removes duplicated node executable arguments on windows", () => {
const execPath = "C:\\Program Files\\nodejs\\node.exe";
const argv = ["node", execPath, "C:\\repo\\openclaw.mjs", execPath, "status"];
expect(
normalizeWindowsArgv(argv, {
platform: "win32",
execPath,
}),
).toEqual(["node", "C:\\repo\\openclaw.mjs", "status"]);
});
it("strips control chars and wrapping quotes before exec-path matching", () => {
const execPath = "C:\\Program Files\\nodejs\\node.exe";
const argv = ["node", `"\u0000${execPath}\u0000"`, "C:\\repo\\openclaw.mjs", "status"];
expect(
normalizeWindowsArgv(argv, {
platform: "win32",
execPath,
existsSync: () => true,
}),
).toEqual(["node", "C:\\repo\\openclaw.mjs", "status"]);
});
});