From 1500547afa9c7784967f1915398bc4e1b3a18e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Lenksj=C3=B6?= Date: Mon, 4 May 2020 16:06:47 +0200 Subject: fix: URL constructor throws confusing error on invalid scheme (#5057) --- cli/js/tests/url_test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'cli/js/tests') diff --git a/cli/js/tests/url_test.ts b/cli/js/tests/url_test.ts index 12e7cb26a..6529bf055 100644 --- a/cli/js/tests/url_test.ts +++ b/cli/js/tests/url_test.ts @@ -224,7 +224,7 @@ unitTest(function throwForInvalidPortConstructor(): void { ]; for (const url of urls) { - assertThrows(() => new URL(url)); + assertThrows(() => new URL(url), TypeError, "Invalid URL."); } // Do not throw for 0 & 65535 @@ -232,6 +232,14 @@ unitTest(function throwForInvalidPortConstructor(): void { new URL("https://baz.qat:0"); }); +unitTest(function throwForInvalidSchemeConstructor(): void { + assertThrows( + () => new URL("invalid_scheme://baz.qat"), + TypeError, + "Invalid URL." + ); +}); + unitTest(function doNotOverridePortIfInvalid(): void { const initialPort = "3000"; const ports = [ -- cgit v1.2.3