refactor: simplify www test (#1895)
This commit is contained in:
+9
-14
@@ -1,25 +1,20 @@
|
|||||||
import { assertArrayIncludes, assertEquals } from "$std/testing/asserts.ts";
|
import { assertArrayIncludes, assertEquals } from "$std/testing/asserts.ts";
|
||||||
import { startFreshServer, withPageName } from "../tests/test_utils.ts";
|
import { withPageName } from "../tests/test_utils.ts";
|
||||||
import { dirname, join } from "$std/path/mod.ts";
|
import { dirname, join } from "$std/path/mod.ts";
|
||||||
import VERSIONS from "../versions.json" assert { type: "json" };
|
import VERSIONS from "../versions.json" assert { type: "json" };
|
||||||
|
import { createHandler } from "../server.ts";
|
||||||
|
import manifest from "./fresh.gen.ts";
|
||||||
|
import config from "./fresh.config.ts";
|
||||||
|
|
||||||
const dir = dirname(import.meta.url);
|
const dir = dirname(import.meta.url);
|
||||||
|
const handler = await createHandler(manifest, config);
|
||||||
|
|
||||||
Deno.test("CORS should not set on GET /fresh-badge.svg", async () => {
|
Deno.test("CORS should not set on GET /fresh-badge.svg", async () => {
|
||||||
const { serverProcess, lines, address } = await startFreshServer({
|
const req = new Request("http://localhost/fresh-badge.svg");
|
||||||
args: ["run", "-A", join(dir, "./main.ts")],
|
const resp = await handler(req);
|
||||||
});
|
await resp?.body?.cancel();
|
||||||
|
|
||||||
const res = await fetch(`${address}/fresh-badge.svg`);
|
assertEquals(resp.headers.get("cross-origin-resource-policy"), null);
|
||||||
await res.body?.cancel();
|
|
||||||
|
|
||||||
assertEquals(res.headers.get("cross-origin-resource-policy"), null);
|
|
||||||
|
|
||||||
serverProcess.kill("SIGTERM");
|
|
||||||
await serverProcess.status;
|
|
||||||
|
|
||||||
// Drain the lines stream
|
|
||||||
for await (const _ of lines) { /* noop */ }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test("shows version selector", async () => {
|
Deno.test("shows version selector", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user