From c1efde757d36930f9a50af33aefe3cb5aa7e2ff9 Mon Sep 17 00:00:00 2001 From: maaz519 Date: Wed, 27 May 2026 14:27:07 +0530 Subject: [PATCH] feat: add health check module with unit tests --- .../modules/health/health.controller.spec.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 apps/api/src/modules/health/health.controller.spec.ts diff --git a/apps/api/src/modules/health/health.controller.spec.ts b/apps/api/src/modules/health/health.controller.spec.ts new file mode 100644 index 0000000..7ee3c86 --- /dev/null +++ b/apps/api/src/modules/health/health.controller.spec.ts @@ -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); + }); + + 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'); + }); +});