Skip to content

Commit

Permalink
chore: improving tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasgriffintn committed Oct 16, 2023
1 parent 63d146a commit e73df6d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions test/tests/consumer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,27 +480,25 @@ describe('Consumer', () => {
});

it('calls the preReceiveMessageCallback and postReceiveMessageCallback function before receiving a message', async () => {
let callbackCalls = 0;
const preReceiveMessageCallbackStub = sandbox.stub().resolves(null);
const postReceiveMessageCallbackStub = sandbox.stub().resolves(null);

consumer = new Consumer({
queueUrl: QUEUE_URL,
region: REGION,
handleMessage,
sqs,
authenticationErrorTimeout: AUTHENTICATION_ERROR_TIMEOUT,
preReceiveMessageCallback: async () => {
callbackCalls++;
},
postReceiveMessageCallback: async () => {
callbackCalls++;
}
preReceiveMessageCallback: preReceiveMessageCallbackStub,
postReceiveMessageCallback: postReceiveMessageCallbackStub
});

consumer.start();
await pEvent(consumer, 'message_processed');
consumer.stop();

assert.equal(callbackCalls, 2);
sandbox.assert.calledOnce(preReceiveMessageCallbackStub);
sandbox.assert.calledOnce(postReceiveMessageCallbackStub);
});

it('deletes the message when the handleMessage function is called', async () => {
Expand Down

0 comments on commit e73df6d

Please sign in to comment.