Skip to content

Commit

Permalink
test(bull-explorer): update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony133 committed Jan 4, 2021
1 parent bfdda41 commit 13d4a08
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions lib/test/bull.explorer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
import { Test } from '@nestjs/testing';
import { Test, TestingModule } from '@nestjs/testing';
import { BullExplorer } from '../bull.explorer';
import { BullModule } from '../bull.module';
import { getQueueToken } from '../utils';

describe('bullExplorer', () => {
describe('BullExplorer', () => {
let bullExplorer: BullExplorer;
beforeEach(async () => {
const moduleRef = await Test.createTestingModule({
imports: [BullModule.registerQueue({ name: 'test' })],
let moduleRef: TestingModule;

beforeAll(async () => {
moduleRef = await Test.createTestingModule({
imports: [
BullModule.registerQueue({ name: 'test', redis: { port: 6380 } }),
],
}).compile();

bullExplorer = moduleRef.get(BullExplorer);
});
afterAll(async () => {
await moduleRef.get(getQueueToken('test')).close();
await moduleRef.close();
});
describe('handleProcessor', () => {
it('should add the given function to the queue handlers', () => {
const instance = { handler: jest.fn() };
Expand Down Expand Up @@ -97,12 +105,11 @@ describe('bullExplorer', () => {
const instance = { handler: jest.fn() };
const queue = { on: jest.fn() } as any;
const opts = { eventName: 'test' } as any;
const wrapper = InstanceWrapper;

const wrapper = new InstanceWrapper();
bullExplorer.handleListener(
instance,
'handler',
new wrapper(),
wrapper,
queue,
opts,
);
Expand Down Expand Up @@ -130,6 +137,8 @@ describe('bullExplorer', () => {
const queue = explorer.getQueue(queueToken, 'test');
expect(queue).toBeDefined();
expect(queue).toBe(fakeQueue);

await moduleRef.close();
});
});
});
});

0 comments on commit 13d4a08

Please sign in to comment.