diff options
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 } }, |