diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2022-08-22 17:01:43 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-22 17:01:43 +0900 |
commit | 57d48134d168cc128f075cb7381d773ea028c81e (patch) | |
tree | e60a5ef22ffb9e6b42aaded54ed5c42f3988f4d1 /cli/tests/unit/flash_test.ts | |
parent | 301f6c46ba4491e9aec76037ae9d01365693b0e4 (diff) |
fix(ext/flash): fix default onListen callback (#15533)
Diffstat (limited to 'cli/tests/unit/flash_test.ts')
-rw-r--r-- | cli/tests/unit/flash_test.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts index fdad1e3ae..fb96e66be 100644 --- a/cli/tests/unit/flash_test.ts +++ b/cli/tests/unit/flash_test.ts @@ -101,6 +101,40 @@ Deno.test({ permissions: { net: true } }, async function httpServerPort0() { await server; }); +Deno.test( + { permissions: { net: true } }, + async function httpServerDefaultOnListenCallback() { + const ac = new AbortController(); + + const consoleLog = console.log; + console.log = (msg) => { + try { + const match = msg.match(/Listening on http:\/\/localhost:(\d+)\//); + assert(!!match); + const port = +match[1]; + assert(port > 0 && port < 65536); + } finally { + ac.abort(); + } + }; + + try { + const server = Deno.serve({ + fetch() { + return new Response("Hello World"); + }, + hostname: "0.0.0.0", + port: 0, + signal: ac.signal, + }); + + await server; + } finally { + console.log = consoleLog; + } + }, +); + // https://github.com/denoland/deno/issues/15107 Deno.test( { permissions: { net: true } }, |