Skip to content

Commit 49a79a4

Browse files
committed
test(parser): add regression tests for hyphen-prefixed string values (#171)
Ensure string args starting with `-` are correctly parsed.
1 parent 31fa24b commit 49a79a4

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

test/parser.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,28 @@ describe("parseRawArgs", () => {
9191
});
9292
});
9393

94+
it("handles string values starting with a hyphen (#171)", () => {
95+
const result = parseRawArgs(["--params", "-a 192.168.1.1 -b -c"], {
96+
string: ["params"],
97+
});
98+
99+
expect(result).toEqual({
100+
_: [],
101+
params: "-a 192.168.1.1 -b -c",
102+
});
103+
});
104+
105+
it("handles string value that is a single hyphen-prefixed token (#171)", () => {
106+
const result = parseRawArgs(["--name", "-test"], {
107+
string: ["name"],
108+
});
109+
110+
expect(result).toEqual({
111+
_: [],
112+
name: "-test",
113+
});
114+
});
115+
94116
it("handles empty arguments", () => {
95117
const result = parseRawArgs([], {});
96118

0 commit comments

Comments
 (0)