Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(async () => {
const moduleFixture = await Test.createTestingModule({
providers: [SubscribeService],
imports: [
RabbitMQModule.forRoot(RabbitMQModule, {
exchanges: [
{
name: exchange,
type: 'topic',
},
],
uri,
}),
],
}).compile();
app = moduleFixture.createNestApplication();
amqpConnection = app.get(AmqpConnection);
await app.init();
});
it('should configure RabbitMQ', async () => {
const spy = jest.spyOn(amqplib, 'connect');
app = await Test.createTestingModule({
imports: [
RabbitMQModule.forRoot(RabbitMQModule, {
uri,
}),
],
}).compile();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(uri);
});
});