Tests and coverage for web

This commit is contained in:
Cadence Ember
2024-12-24 01:06:19 +13:00
parent 53379a962d
commit c599dff590
17 changed files with 593 additions and 171 deletions

32
src/web/server.test.js Normal file
View File

@@ -0,0 +1,32 @@
// @ts-check
const {test} = require("supertape")
const {router} = require("../../test/web")
require("./server")
test("web server: can get home", async t => {
t.match(await router.test("get", "/", {}), /Add the bot to your Discord server./)
})
test("web server: can get htmx", async t => {
t.match(await router.test("get", "/static/htmx.min.js", {}), /htmx=/)
})
test("web server: can get css", async t => {
t.match(await router.test("get", "/static/stacks.min.css", {}), /--stacks-/)
})
test("web server: can get icon", async t => {
const content = await router.test("get", "/icon.png", {})
t.ok(content instanceof Buffer)
})
test("web server: compresses static resources", async t => {
const content = await router.test("get", "/static/stacks.min.css", {
headers: {
"accept-encoding": "gzip"
}
})
t.ok(content instanceof ReadableStream)
})