Files
openclaw/test/scripts/arg-utils.test.ts
2026-05-24 18:13:14 +02:00

29 lines
756 B
TypeScript

import { describe, expect, it } from "vitest";
import { intFlag, parseFlagArgs } from "../../scripts/lib/arg-utils.mjs";
describe("scripts/lib/arg-utils parseFlagArgs", () => {
it("ignores the conventional option separator by default", () => {
const parsed = parseFlagArgs(
["--", "--limit", "30"],
{ limit: 10 },
[intFlag("--limit", "limit", { min: 1 })],
);
expect(parsed.limit).toBe(30);
});
it("can preserve the option separator for callers that need to handle it", () => {
const seen: string[] = [];
parseFlagArgs(["--"], {}, [], {
ignoreDoubleDash: false,
onUnhandledArg(arg) {
seen.push(arg);
return "handled";
},
});
expect(seen).toEqual(["--"]);
});
});