46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
|
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||
|
|
import { FastifyInstance } from 'fastify';
|
||
|
|
import { createServer } from '../src/index';
|
||
|
|
|
||
|
|
describe('Intake Service', () => {
|
||
|
|
let server: FastifyInstance;
|
||
|
|
|
||
|
|
beforeEach(async () => {
|
||
|
|
server = await createServer();
|
||
|
|
await server.ready();
|
||
|
|
});
|
||
|
|
|
||
|
|
afterEach(async () => {
|
||
|
|
await server.close();
|
||
|
|
});
|
||
|
|
|
||
|
|
describe('Health Check', () => {
|
||
|
|
it('should return 200 on health check', async () => {
|
||
|
|
const response = await server.inject({
|
||
|
|
method: 'GET',
|
||
|
|
url: '/health',
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(response.statusCode).toBe(200);
|
||
|
|
expect(response.json()).toMatchObject({
|
||
|
|
status: 'ok',
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
describe('Document Upload', () => {
|
||
|
|
it('should validate document upload request', async () => {
|
||
|
|
const response = await server.inject({
|
||
|
|
method: 'POST',
|
||
|
|
url: '/api/v1/documents',
|
||
|
|
payload: {
|
||
|
|
// Invalid payload to test validation
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(response.statusCode).toBe(400);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|