import { describe, it, expect, afterEach } from "vitest"; import { buildApp } from "./index.js"; afterEach(async () => { // Each test boots its own server; close it to free the DB handle. // (No shared server state is asserted across tests.) }); describe("server config", () => { it("exposes sensible defaults", async () => { const { config } = await import("./config.js"); expect(config.port).toBe(8080); expect(config.version).toBeTruthy(); expect(typeof config.dbPath).toBe("string"); }); }); describe("health endpoint", () => { it("reports ok and db up", async () => { const app = await buildApp(); try { const res = await app.inject({ method: "GET", url: "/api/health" }); expect(res.statusCode).toBe(200); const body = res.json(); expect(body.ok).toBe(true); expect(body.db).toBe("up"); expect(body.version).toBeTruthy(); } finally { await app.close(); } }); });