Skip to content

Commit

Permalink
test: improve internal/url.js coverage
Browse files Browse the repository at this point in the history
PR-URL: #42650
Refs: https://coverage.nodejs.org/coverage-3c752648d4ef5510/lib/internal/url.js.html#L256
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Akhil Marsonya <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Zijian Liu <[email protected]>
  • Loading branch information
kuriyosh authored and targos committed Jul 11, 2022
1 parent efc36e3 commit bc356ab
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/parallel/test-whatwg-url-custom-searchparams-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ const util = require('util');
const sp = new URLSearchParams('?a=a&b=b&b=c');
assert.strictEqual(util.inspect(sp),
"URLSearchParams { 'a' => 'a', 'b' => 'b', 'b' => 'c' }");
assert.strictEqual(util.inspect(sp, { depth: -1 }), '[Object]');
assert.strictEqual(
util.inspect(sp, { breakLength: 1 }),
"URLSearchParams {\n 'a' => 'a',\n 'b' => 'b',\n 'b' => 'c' }"
);
assert.strictEqual(util.inspect(sp.keys()),
"URLSearchParams Iterator { 'a', 'b', 'b' }");
assert.strictEqual(util.inspect(sp.values()),
"URLSearchParams Iterator { 'a', 'b', 'c' }");
assert.strictEqual(util.inspect(sp.keys(), { breakLength: 1 }),
"URLSearchParams Iterator {\n 'a',\n 'b',\n 'b' }");
assert.throws(() => sp[util.inspect.custom].call(), {
code: 'ERR_INVALID_THIS',
});

const iterator = sp.entries();
assert.strictEqual(util.inspect(iterator),
Expand All @@ -27,3 +35,5 @@ iterator.next();
iterator.next();
assert.strictEqual(util.inspect(iterator),
'URLSearchParams Iterator { }');
const emptySp = new URLSearchParams();
assert.strictEqual(util.inspect(emptySp), 'URLSearchParams {}');

0 comments on commit bc356ab

Please sign in to comment.