Files
time/quc/test/worker.test.js
T
time 7a805ce5ae
ci / test (push) Successful in 45s
sync / sync (push) Successful in 8s
time/worker-run grep -rniE "quc" --include=*.md --include=*.json . -l | head; grep -rniE "tone|voice" README.md .cla
Scaffold quc app shell, health check and Cloudflare deploy (#237)
Co-authored-by: Time <time@users.noreply.teahub.xyz>
2026-10-22 08:40:28 +00:00

28 lines
1.0 KiB
JavaScript

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);
});