mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-03 04:01:36 +00:00
* test(cli): add unit tests for CLI argument quoting helper * ci: trigger re-review * ci: trigger re-review * ci: trigger re-review * ci: retrigger * fix: correct empty string assertion in quoteCliArg test * ci: trigger re-review * ci: trigger re-review * test(cli): add shell metacharacter tests for quoteCliArg * test(cli): expand argument quoting coverage --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
24 lines
716 B
TypeScript
24 lines
716 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { quoteCliArg } from "./quote-cli-arg.js";
|
|
|
|
describe("quoteCliArg", () => {
|
|
it.each([
|
|
["hello", "hello"],
|
|
["/usr/bin/node", "/usr/bin/node"],
|
|
["--flag=alpha,beta", "--flag=alpha,beta"],
|
|
["", "''"],
|
|
["hello world", "'hello world'"],
|
|
["it's", "'it'\\''s'"],
|
|
["$PATH", "'$PATH'"],
|
|
["build & run", "'build & run'"],
|
|
["cat file | grep x", "'cat file | grep x'"],
|
|
["*.txt", "'*.txt'"],
|
|
["$(whoami)", "'$(whoami)'"],
|
|
["`whoami`", "'`whoami`'"],
|
|
["echo; rm", "'echo; rm'"],
|
|
["line\nbreak", "'line\nbreak'"],
|
|
])("quotes %j as %j", (value, expected) => {
|
|
expect(quoteCliArg(value)).toBe(expected);
|
|
});
|
|
});
|