50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { INestApplication } from '@nestjs/common';
|
|
import * as request from 'supertest';
|
|
import { HealthModule } from '../src/modules/health/health.module';
|
|
|
|
describe('HealthController (e2e)', () => {
|
|
let app: INestApplication;
|
|
|
|
beforeAll(async () => {
|
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
imports: [HealthModule],
|
|
}).compile();
|
|
|
|
app = moduleFixture.createNestApplication();
|
|
await app.init();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await app.close();
|
|
});
|
|
|
|
describe('GET /health', () => {
|
|
it('should return health status', async () => {
|
|
const response = await request(app.getHttpServer())
|
|
.get('/health')
|
|
.expect(200);
|
|
|
|
expect(response.body).toMatchObject({
|
|
status: 'ok',
|
|
service: 'miinventario-api',
|
|
version: '0.1.0',
|
|
});
|
|
expect(response.body.timestamp).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('GET /health/ready', () => {
|
|
it('should return readiness status', async () => {
|
|
const response = await request(app.getHttpServer())
|
|
.get('/health/ready')
|
|
.expect(200);
|
|
|
|
expect(response.body).toMatchObject({
|
|
status: 'ready',
|
|
});
|
|
expect(response.body.timestamp).toBeDefined();
|
|
});
|
|
});
|
|
});
|