From 9d6af7d1fe66afdcb781fb5bad37b4cb4d396f0e Mon Sep 17 00:00:00 2001 From: Yoshiki Kurihara Date: Wed, 13 Apr 2022 17:35:09 +0900 Subject: [PATCH] test: improve `internal/url.js` coverage PR-URL: https://github.com/nodejs/node/pull/42650 Refs: https://coverage.nodejs.org/coverage-3c752648d4ef5510/lib/internal/url.js.html#L256 Reviewed-By: Antoine du Hamel Reviewed-By: Colin Ihrig Reviewed-By: Akhil Marsonya Reviewed-By: Darshan Sen Reviewed-By: Zijian Liu --- .../test-whatwg-url-custom-searchparams-inspect.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/parallel/test-whatwg-url-custom-searchparams-inspect.js b/test/parallel/test-whatwg-url-custom-searchparams-inspect.js index c03890938d9cfe..7729a36eb8fd9f 100644 --- a/test/parallel/test-whatwg-url-custom-searchparams-inspect.js +++ b/test/parallel/test-whatwg-url-custom-searchparams-inspect.js @@ -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), @@ -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 {}');