mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
test: complete coverage of querystring
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
4f1ba79eb8
commit
726cb48bd8
1 file changed
+9
@@ -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
|
||||
@@ -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]);
|
||||
|
||||
Reference in new issue
Block a user