Tests refactor

This commit is contained in:
Aerilyn Weber 2026-05-19 11:06:03 +09:00
parent 245520fb50
commit 99134d8556
165 changed files with 911 additions and 531 deletions

View file

@ -0,0 +1,40 @@
import { describe, it, expect } from 'vitest';
import Fastify from 'fastify';
import { serializerCompiler, validatorCompiler } from 'fastify-type-provider-zod';
import healthRoutes from '../../../src/modules/health/health.routes.js';
describe('Health Routes', () => {
async function buildTestApp() {
const app = Fastify({ logger: false });
app.setValidatorCompiler(validatorCompiler);
app.setSerializerCompiler(serializerCompiler);
await app.register(healthRoutes);
return app;
}
it('GET /api/v1/health returns 200 with status ok', async () => {
const app = await buildTestApp();
const response = await app.inject({
method: 'GET',
url: '/api/v1/health',
});
expect(response.statusCode).toBe(200);
const body = response.json();
expect(body).toMatchObject({
status: 'ok',
version: expect.any(String),
uptime: expect.any(Number),
});
});
it('GET /api/v1/health returns increasing uptime', async () => {
const app = await buildTestApp();
const first = await app.inject({ method: 'GET', url: '/api/v1/health' });
const second = await app.inject({ method: 'GET', url: '/api/v1/health' });
expect(second.json().uptime).toBeGreaterThanOrEqual(first.json().uptime);
});
});