/** * API integration tests for the health check endpoint. * Tests the /api/health route which is public (no auth required). */ import { describe, it, expect } from 'bun:test'; import { Hono } from 'hono'; // Create a minimal test app that mirrors the health endpoint function createTestApp() { const app = new Hono(); app.get('/api/health', (c) => { return c.json({ code: 0, data: { status: 'ok', version: '1.0.0', uptime: Math.floor(process.uptime()), dbConnected: true, }, message: 'success', }); }); return app; } describe('GET /api/health', () => { const app = createTestApp(); it('should return 200 with health data', async () => { const res = await app.request('/api/health'); expect(res.status).toBe(200); const body = await res.json(); expect(body.code).toBe(0); expect(body.message).toBe('success'); expect(body.data.status).toBe('ok'); expect(body.data.version).toBe('1.0.0'); expect(typeof body.data.uptime).toBe('number'); expect(body.data.dbConnected).toBe(true); }); it('should return correct content-type', async () => { const res = await app.request('/api/health'); const contentType = res.headers.get('content-type'); expect(contentType).toContain('application/json'); }); });