diff options
author | ayame113 <40050810+ayame113@users.noreply.github.com> | 2022-07-20 19:30:41 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-20 18:30:41 +0800 |
commit | 27a72a12b772cfa74b519714aca6e3b6fdaa5eeb (patch) | |
tree | 7a36d0494797e3296f1deae51e733378f2abfd99 /cli/tests/unit | |
parent | b8e1250500ba07971b2f05847fdcbbfe548caa44 (diff) |
chore: align some Web API type definitions to lib.dom.d.ts (#15219)
Diffstat (limited to 'cli/tests/unit')
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 8 | ||||
-rw-r--r-- | cli/tests/unit/request_test.ts | 7 | ||||
-rw-r--r-- | cli/tests/unit/url_test.ts | 12 | ||||
-rw-r--r-- | cli/tests/unit/websocket_test.ts | 14 |
4 files changed, 40 insertions, 1 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index 7adbb7721..72660c547 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -818,6 +818,14 @@ Deno.test(function responseRedirect() { assertEquals(redir.type, "default"); }); +Deno.test(function responseRedirectTakeURLObjectAsParameter() { + const redir = Response.redirect(new URL("https://example.com/")); + assertEquals( + redir.headers.get("Location"), + "https://example.com/", + ); +}); + Deno.test(async function responseWithoutBody() { const response = new Response(); assertEquals(await response.arrayBuffer(), new ArrayBuffer(0)); diff --git a/cli/tests/unit/request_test.ts b/cli/tests/unit/request_test.ts index 41a1d7e2f..68f7a86c1 100644 --- a/cli/tests/unit/request_test.ts +++ b/cli/tests/unit/request_test.ts @@ -68,3 +68,10 @@ Deno.test(function customInspectFunction() { ); assertStringIncludes(Deno.inspect(Request.prototype), "Request"); }); + +Deno.test(function requestConstructorTakeURLObjectAsParameter() { + assertEquals( + new Request(new URL("http://foo/")).url, + "http://foo/", + ); +}); diff --git a/cli/tests/unit/url_test.ts b/cli/tests/unit/url_test.ts index 3d4e1aa2c..0ba848add 100644 --- a/cli/tests/unit/url_test.ts +++ b/cli/tests/unit/url_test.ts @@ -494,3 +494,15 @@ Deno.test(function urlSearchParamsIdentityPreserved() { const sp2 = u.searchParams; assertStrictEquals(sp1, sp2); }); + +Deno.test(function urlTakeURLObjectAsParameter() { + const url = new URL( + new URL( + "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat", + ), + ); + assertEquals( + url.href, + "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat", + ); +}); diff --git a/cli/tests/unit/websocket_test.ts b/cli/tests/unit/websocket_test.ts index f033c5ac4..6bd35efca 100644 --- a/cli/tests/unit/websocket_test.ts +++ b/cli/tests/unit/websocket_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { assertThrows } from "./test_util.ts"; +import { assertEquals, assertThrows, deferred, fail } from "./test_util.ts"; Deno.test({ permissions: "none" }, function websocketPermissionless() { assertThrows( @@ -7,3 +7,15 @@ Deno.test({ permissions: "none" }, function websocketPermissionless() { Deno.errors.PermissionDenied, ); }); + +Deno.test(async function websocketConstructorTakeURLObjectAsParameter() { + const promise = deferred(); + const ws = new WebSocket(new URL("ws://localhost:4242/")); + assertEquals(ws.url, "ws://localhost:4242/"); + ws.onerror = () => fail(); + ws.onopen = () => ws.close(); + ws.onclose = () => { + promise.resolve(); + }; + await promise; +}); |