Skip to content

Commit 4a383c8

Browse files
committed
test: complete coverage of querystring
1 parent 63c9b5b commit 4a383c8

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

test/parallel/test-querystring.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ assert.strictEqual(qs.stringify({ foo: -0 }), 'foo=0');
307307
assert.strictEqual(qs.stringify({ foo: 3 }), 'foo=3');
308308
assert.strictEqual(qs.stringify({ foo: -72.42 }), 'foo=-72.42');
309309
assert.strictEqual(qs.stringify({ foo: NaN }), 'foo=');
310+
assert.strictEqual(qs.stringify({ foo: 1e21 }), 'foo=1e%2B21');
310311
assert.strictEqual(qs.stringify({ foo: Infinity }), 'foo=');
311312

312313
// nested
@@ -450,6 +451,14 @@ check(qs.parse('%\u0100=%\u0101'), { '%Ā': '%ā' });
450451
'a=a&b=b&c=c');
451452
}
452453

454+
// Test custom encode for different types
455+
{
456+
const obj = { number: 1, bigint: 2n, true: true, false: false, object: {} };
457+
assert.strictEqual(
458+
qs.stringify(obj, null, null, { encodeURIComponent: v => v }),
459+
'number=1&bigint=2&true=true&false=false&object=');
460+
}
461+
453462
// Test QueryString.unescapeBuffer
454463
qsUnescapeTestCases.forEach((testCase) => {
455464
assert.strictEqual(qs.unescape(testCase[0]), testCase[1]);

0 commit comments

Comments
 (0)