Scaffold quc app shell, health check and Cloudflare deploy (#237)
Co-authored-by: Time <time@users.noreply.teahub.xyz>
This commit was merged in pull request #237.
This commit is contained in:
1 parent
2f112ef3c5
commit
7a805ce5ae
6 files changed
+187
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import worker from "../src/worker.js";
|
||||
|
||||
const get = (path, env, method = "GET") => worker.fetch(new Request("http://x" + path, { method }), env);
|
||||
|
||||
test("health reports ok and the revision", async () => {
|
||||
const r = await get("/api/health", { REV: "abc" });
|
||||
assert.equal(r.status, 200);
|
||||
assert.deepEqual(await r.json(), { ok: true, rev: "abc" });
|
||||
});
|
||||
|
||||
test("shell is responsive html that loads the motif", async () => {
|
||||
const r = await get("/");
|
||||
const html = await r.text();
|
||||
assert.match(r.headers.get("content-type"), /text\/html/);
|
||||
assert.match(html, /name="viewport" content="width=device-width/);
|
||||
assert.match(html, /chair\.svg/);
|
||||
});
|
||||
|
||||
test("motif is an svg, unknown paths 404, writes are refused", async () => {
|
||||
const svg = await get("/chair.svg");
|
||||
assert.equal(svg.headers.get("content-type"), "image/svg+xml");
|
||||
assert.match(await svg.text(), /^<svg/);
|
||||
assert.equal((await get("/nope")).status, 404);
|
||||
assert.equal((await get("/api/health", {}, "POST")).status, 405);
|
||||
});
|
||||
Reference in new issue
Block a user