mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-21 16:41:56 +00:00
test: add tests for extraArgs filtering logic
Address review feedback: add tests covering empty strings, non-strings, mixed arrays, and non-array inputs for extraArgs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
cc3c25e413
commit
47f8c9209f
@@ -149,4 +149,37 @@ describe("browser config", () => {
|
||||
expect(resolveProfile(resolved, "chrome")).toBe(null);
|
||||
expect(resolved.defaultProfile).toBe("openclaw");
|
||||
});
|
||||
|
||||
it("defaults extraArgs to empty array when not provided", () => {
|
||||
const resolved = resolveBrowserConfig(undefined);
|
||||
expect(resolved.extraArgs).toEqual([]);
|
||||
});
|
||||
|
||||
it("passes through valid extraArgs strings", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
extraArgs: ["--no-sandbox", "--disable-gpu"],
|
||||
});
|
||||
expect(resolved.extraArgs).toEqual(["--no-sandbox", "--disable-gpu"]);
|
||||
});
|
||||
|
||||
it("filters out empty strings and whitespace-only entries from extraArgs", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
extraArgs: ["--flag", "", " ", "--other"],
|
||||
});
|
||||
expect(resolved.extraArgs).toEqual(["--flag", "--other"]);
|
||||
});
|
||||
|
||||
it("filters out non-string entries from extraArgs", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
extraArgs: ["--flag", 42, null, undefined, true, "--other"] as unknown as string[],
|
||||
});
|
||||
expect(resolved.extraArgs).toEqual(["--flag", "--other"]);
|
||||
});
|
||||
|
||||
it("defaults extraArgs to empty array when set to non-array", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
extraArgs: "not-an-array" as unknown as string[],
|
||||
});
|
||||
expect(resolved.extraArgs).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user