diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-08-24 16:38:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 16:38:51 +0200 |
commit | a4cc09447e73d27b15201e7240fa056f06e34b9f (patch) | |
tree | 630e06ce3228a7b8a413afd7555764d9a437cb06 /cli/tests/unit/flash_test.ts | |
parent | 5268fa0e0f34571f0fc615eb665747863aca311e (diff) |
fix(unstable): Deno.serve() can parse hostnames (#15579)
Diffstat (limited to 'cli/tests/unit/flash_test.ts')
-rw-r--r-- | cli/tests/unit/flash_test.ts | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts index c718c1b2e..89e91fd7a 100644 --- a/cli/tests/unit/flash_test.ts +++ b/cli/tests/unit/flash_test.ts @@ -34,16 +34,27 @@ function onListen<T>( }; } -Deno.test(async function httpServerInvalidHostname() { - await assertRejects( - () => - Deno.serve({ - handler: (_req) => new Response("ok"), - hostname: "localhost", - }), - TypeError, - "hostname could not be parsed as an IP address", - ); +Deno.test(async function httpServerCanResolveHostnames() { + const ac = new AbortController(); + const listeningPromise = deferred(); + + const server = Deno.serve({ + handler: (_req) => new Response("ok"), + hostname: "localhost", + port: 4501, + signal: ac.signal, + onListen: onListen(listeningPromise), + onError: createOnErrorCb(ac), + }); + + await listeningPromise; + const resp = await fetch("http://localhost:4501/", { + headers: { "connection": "close" }, + }); + const text = await resp.text(); + assertEquals(text, "ok"); + ac.abort(); + await server; }); Deno.test({ permissions: { net: true } }, async function httpServerBasic() { |