Skip to content

Commit

Permalink
test: add test to producer class
Browse files Browse the repository at this point in the history
  • Loading branch information
orig committed Sep 24, 2023
1 parent f394bd6 commit 15f3141
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libs/queue-manager/src/lib/producer/producer.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ describe('ProducerService', () => {
expect(queueManagerSpy).toBeCalledTimes(0);
});

it('should not publish a message to the queue if queue-manager is disabled', async () => {
const configMock = jest.spyOn(configService, 'getConfig');
configMock.mockReturnValue({ general: { env: 'development' }, memphis: { enable: false } } as any);

const queueManagerSpy = jest.spyOn(queueManager.client, 'produce');

const PAYLOAD = { message: 'test', 1: 2 };

await service.publish(PAYLOAD);
expect(queueManagerSpy).toBeCalledTimes(0);
});

// It is not actually going to publish a message to the queue, but it is going to call the produce method of the queue-manager mock
it('should publish a message to the queue if we are not in test environment', async () => {
// Mock the config service to return the development environment
Expand Down

0 comments on commit 15f3141

Please sign in to comment.