Skip to content

Commit 726cb48

Browse files
pd4d10targos
authored andcommitted
test: complete coverage of querystring
PR-URL: #38520 Refs: https://coverage.nodejs.org/coverage-68e6673224365120/lib/querystring.js.html#L179 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent 4f1ba79 commit 726cb48

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/parallel/test-querystring.js

+9
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)