Skip to content

Commit

Permalink
test: complete coverage of querystring
Browse files Browse the repository at this point in the history
PR-URL: #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]>
  • Loading branch information
pd4d10 authored and targos committed Jun 5, 2021
1 parent f92bc29 commit 4056af6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/parallel/test-querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ assert.strictEqual(qs.stringify({ foo: -0 }), 'foo=0');
assert.strictEqual(qs.stringify({ foo: 3 }), 'foo=3');
assert.strictEqual(qs.stringify({ foo: -72.42 }), 'foo=-72.42');
assert.strictEqual(qs.stringify({ foo: NaN }), 'foo=');
assert.strictEqual(qs.stringify({ foo: 1e21 }), 'foo=1e%2B21');
assert.strictEqual(qs.stringify({ foo: Infinity }), 'foo=');

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

// Test custom encode for different types
{
const obj = { number: 1, bigint: 2n, true: true, false: false, object: {} };
assert.strictEqual(
qs.stringify(obj, null, null, { encodeURIComponent: (v) => v }),
'number=1&bigint=2&true=true&false=false&object=');
}

// Test QueryString.unescapeBuffer
qsUnescapeTestCases.forEach((testCase) => {
assert.strictEqual(qs.unescape(testCase[0]), testCase[1]);
Expand Down

0 comments on commit 4056af6

Please sign in to comment.