26 lines
720 B
TypeScript
26 lines
720 B
TypeScript
import { describe, test, expect } from "bun:test";
|
|
import teapot from "../../src/api/teapot";
|
|
|
|
describe("Teapot route handler", () => {
|
|
test("GET / returns 418 status", async () => {
|
|
const res = await teapot.request("/");
|
|
expect(res.status).toBe(418);
|
|
});
|
|
|
|
test("response body has correct shape", async () => {
|
|
const res = await teapot.request("/");
|
|
const body = await res.json();
|
|
expect(body).toEqual({
|
|
status: 418,
|
|
message: "I'm not a teapot",
|
|
successful: true,
|
|
});
|
|
});
|
|
|
|
test("returns JSON content type", async () => {
|
|
const res = await teapot.request("/");
|
|
const ct = res.headers.get("content-type");
|
|
expect(ct).toContain("application/json");
|
|
});
|
|
});
|