From 70bbf6579668d73906af1cfe159df59f770e8133 Mon Sep 17 00:00:00 2001 From: Yoshiki Kurihara Date: Fri, 8 Apr 2022 14:30:48 +0900 Subject: [PATCH] test: improve internal/url.js coverage --- .../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 {}');