|
1 | 1 | import { AddressInfo } from "net"; |
2 | 2 | import { Log, LogLevel } from "@miniflare/shared"; |
3 | | -import { interceptConsoleLogs } from "@miniflare/shared-test"; |
| 3 | +import { interceptConsoleLogs, useTmp } from "@miniflare/shared-test"; |
4 | 4 | import test from "ava"; |
5 | 5 | import { Miniflare, VariedStorageFactory } from "miniflare"; |
6 | 6 | import { fetch } from "undici"; |
@@ -173,3 +173,23 @@ test.serial("Miniflare: startScheduler: starts CRON scheduler", async (t) => { |
173 | 173 | }; |
174 | 174 | await mf.startScheduler(); |
175 | 175 | }); |
| 176 | +test("Miniflare: getOpenURL: returns URL to open browser at", async (t) => { |
| 177 | + // Check returns undefined if open disabled |
| 178 | + const mf = new Miniflare({ script: "//" }); |
| 179 | + t.is(await mf.getOpenURL(), undefined); |
| 180 | + await mf.setOptions({ open: false }); |
| 181 | + t.is(await mf.getOpenURL(), undefined); |
| 182 | + |
| 183 | + // Check returns custom string URL |
| 184 | + await mf.setOptions({ open: "https://some.other.website/" }); |
| 185 | + t.is(await mf.getOpenURL(), "https://some.other.website/"); |
| 186 | + |
| 187 | + // Check returns http URL with default host and port |
| 188 | + await mf.setOptions({ open: true }); |
| 189 | + t.is(await mf.getOpenURL(), "http://localhost:8787/"); |
| 190 | + |
| 191 | + // Check returns https URL with custom host and port |
| 192 | + const tmp = await useTmp(t); |
| 193 | + await mf.setOptions({ open: true, https: tmp, host: "test.mf", port: 3000 }); |
| 194 | + t.is(await mf.getOpenURL(), "https://test.mf:3000/"); |
| 195 | +}); |
0 commit comments