59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { getQueueToken } from '@nestjs/bullmq';
|
|
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { INestApplication } from '@nestjs/common';
|
|
import request from 'supertest';
|
|
import { App } from 'supertest/types';
|
|
import { configureApp } from './../src/app.setup';
|
|
import { AppModule } from './../src/app.module';
|
|
import { ANALYSIS_QUEUE_NAME } from './../src/modules/analysis/analysis.constants';
|
|
import { ConnectionService } from './../src/modules/global/database/connection.service';
|
|
import { REDIS_CLIENT } from './../src/modules/global/redis/redis.constants';
|
|
import { SecretService } from './../src/modules/global/secret/secret.service';
|
|
|
|
describe('AppController (e2e)', () => {
|
|
let app: INestApplication<App>;
|
|
|
|
beforeEach(async () => {
|
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
imports: [AppModule],
|
|
})
|
|
.overrideProvider(ConnectionService)
|
|
.useValue({})
|
|
.overrideProvider(SecretService)
|
|
.useValue({
|
|
get: jest.fn((key: string) => {
|
|
if (key === 'REDIS_URL') {
|
|
return Promise.resolve('redis://localhost:6379/0');
|
|
}
|
|
return Promise.resolve('');
|
|
}),
|
|
ready: jest.fn().mockResolvedValue(undefined),
|
|
})
|
|
.overrideProvider(REDIS_CLIENT)
|
|
.useValue({
|
|
destroy: jest.fn(),
|
|
quit: jest.fn().mockResolvedValue(undefined),
|
|
})
|
|
.overrideProvider(getQueueToken(ANALYSIS_QUEUE_NAME))
|
|
.useValue({
|
|
add: jest.fn(),
|
|
})
|
|
.compile();
|
|
|
|
app = moduleFixture.createNestApplication();
|
|
configureApp(app);
|
|
await app.init();
|
|
});
|
|
|
|
it('/api/health (GET)', () => {
|
|
return request(app.getHttpServer())
|
|
.get('/api/health')
|
|
.expect(200)
|
|
.expect({ status: 'ok' });
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await app.close();
|
|
});
|
|
});
|