summaryrefslogtreecommitdiff
path: root/cli/tests/unit/flash_test.ts
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2022-08-22 17:01:43 +0900
committerGitHub <noreply@github.com>2022-08-22 17:01:43 +0900
commit57d48134d168cc128f075cb7381d773ea028c81e (patch)
treee60a5ef22ffb9e6b42aaded54ed5c42f3988f4d1 /cli/tests/unit/flash_test.ts
parent301f6c46ba4491e9aec76037ae9d01365693b0e4 (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.ts34
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 } },