feat: add health check module with unit tests

This commit is contained in:
2026-05-27 14:27:07 +05:30
parent ae6c7ec94a
commit c1efde757d
@@ -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');
});
});