Setup initial project
This commit is contained in:
commit
db79af06f7
119 changed files with 20761 additions and 0 deletions
40
packages/api/src/modules/health/health.routes.test.ts
Normal file
40
packages/api/src/modules/health/health.routes.test.ts
Normal 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 './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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue