Skip to content

Commit 8157b75

Browse files
committed
test: improve code coverage
1 parent 66bf390 commit 8157b75

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

test/parse.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ test("should accept pairs with missing values", () => {
3535
assert.deepEqual(qs.parse("foo=bar&hey"), { foo: "bar", hey: "" });
3636
assert.deepEqual(qs.parse("hey"), { hey: "" });
3737
});
38+
39+
test("should decode key", () => {
40+
assert.deepEqual(qs.parse("full%20name=Yagiz"), { "full name": "Yagiz" });
41+
});

test/stringify.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,35 @@ test("native querystring module should match the test suite result", () => {
1616
(t) => assert.deepEqual(querystring.stringify(t[1]), t[0]),
1717
);
1818
});
19+
20+
test("should handle numbers", () => {
21+
assert.deepEqual(
22+
qs.stringify({ age: 5, name: "John Doe" }),
23+
"age=5&name=John%20Doe",
24+
);
25+
});
26+
27+
test("should handle BigInt", () => {
28+
assert.deepEqual(
29+
qs.stringify({ age: BigInt(55), name: "John" }),
30+
"age=55&name=John",
31+
);
32+
});
33+
34+
test("should handle boolean values", () => {
35+
assert.deepEqual(qs.stringify({ valid: true }), "valid=true");
36+
assert.deepEqual(qs.stringify({ valid: false }), "valid=false");
37+
});
38+
39+
test("should handle numbers", () => {
40+
assert.deepEqual(qs.stringify({ value: 1e22 }), "value=1e%2B22");
41+
});
42+
43+
test("should omit objects", () => {
44+
// This aligns with querystring module
45+
assert.deepEqual(qs.stringify({ user: {} }), "user=");
46+
});
47+
48+
test("should omit non-object inputs", () => {
49+
assert.deepEqual(qs.stringify("hello" as any), "");
50+
});

0 commit comments

Comments
 (0)