pp-mono/apps/server/__tests__/app.test.ts
2026-03-13 16:15:19 +01:00

33 lines
961 B
TypeScript

import { describe, it, expect, beforeAll } from "vitest";
// Auth.js requires AUTH_SECRET to be set
beforeAll(() => {
process.env.AUTH_SECRET = "test-secret-at-least-32-chars-long!!";
});
// Dynamic import so env is set before module loads
const { app } = await import("../src/index.js");
describe("Health endpoint", () => {
it("GET /api/health returns 200 with status ok", async () => {
const res = await app.request("/api/health");
expect(res.status).toBe(200);
const body = await res.json();
expect(body).toEqual({ status: "ok" });
});
});
describe("Auth routes", () => {
it("GET /api/auth/providers returns JSON with github and google", async () => {
const res = await app.request("/api/auth/providers");
// Auth.js providers endpoint should return 200
expect(res.status).toBe(200);
const body = await res.json();
expect(body).toHaveProperty("github");
expect(body).toHaveProperty("google");
});
});