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 <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
  • Loading branch information
kuriyosh committed Apr 13, 2022
1 parent 3671cc0 commit 9d6af7d
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
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 9d6af7d

Please sign in to comment.