Skip to content

Commit efd70f4

Browse files
pd4d10jasnell
authored andcommitted
test: complete coverage of querystring
PR-URL: nodejs#38520 Refs: https://coverage.nodejs.org/coverage-68e6673224365120/lib/querystring.js.html#L179 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent 7d74487 commit efd70f4

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)