-
Marlène SIMONDANT authoredMarlène SIMONDANT authored
app.controller.spec.ts 851 B
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
describe('AppController', () => {
let app: TestingModule;
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
}).compile();
});
describe('healthcheck', () => {
it('should return "Hello World!"', async () => {
const appController = app.get<AppController>(AppController);
const result = { status: 'API Online', uptime: 1, version: '' };
jest
.spyOn(appController, 'healthcheck')
.mockImplementation(async (): Promise<{ status; uptime; version }> => result);
const healthcheck = await appController.healthcheck();
expect(healthcheck.status).toBe(result.status);
expect(healthcheck.uptime).toBe(result.uptime);
});
});
});