/
app.module.spec.ts
46 lines (41 loc) · 1.17 KB
/
app.module.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { BullModule } from '@nestjs/bull';
describe('AppModule', () => {
let appController: AppController;
let app: TestingModule;
const mockFn = jest.fn(() => 'I was not supposed to run');
beforeEach(async () => {
app = await Test.createTestingModule({
imports: [
BullModule.registerQueue({
prefix: `${process.pid}`,
name: 'bullissue',
redis: {
host: 'localhost',
port: 6379,
},
processors: [{ name: 'test', callback: mockFn }]
}),
],
controllers: [AppController],
providers: [AppService],
}).compile();
appController = app.get<AppController>(AppController);
});
afterAll(async () => {
await app.close();
});
describe('root', () => {
it('should return "Hello World!"', async () => {
await appController.getHello();
return new Promise(resolve => {
setTimeout(() => {
expect(mockFn).toBeCalledTimes(1);
resolve();
}, 1000);
});
});
});
});