feat: add health check module with unit tests
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { HealthController } from './health.controller';
|
||||
|
||||
describe('HealthController', () => {
|
||||
let controller: HealthController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [HealthController],
|
||||
}).compile();
|
||||
controller = module.get<HealthController>(HealthController);
|
||||
});
|
||||
|
||||
it('returns status "ok"', () => {
|
||||
const result = controller.check();
|
||||
expect(result.status).toBe('ok');
|
||||
});
|
||||
|
||||
it('returns an ISO timestamp', () => {
|
||||
const result = controller.check();
|
||||
expect(() => new Date(result.timestamp)).not.toThrow();
|
||||
expect(result.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T/);
|
||||
});
|
||||
|
||||
it('returns the service name', () => {
|
||||
const result = controller.check();
|
||||
expect(result.service).toBe('tower-api');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user