Skip to content

Commit

Permalink
Increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
vdfdev committed Aug 10, 2021
1 parent 8dc0040 commit 412d230
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/server/transport/pubsub/redis-pub-sub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ describe('redis pub-sub', () => {
});

it('should receive a message after subscription', () => {
const callback = jest.fn();
const callback1 = jest.fn();
const callback2 = jest.fn();
const payload = 'hello world';
pubSub.subscribe(CHANNEL_FOO, callback);
pubSub.subscribe(CHANNEL_FOO, callback1);
pubSub.subscribe(CHANNEL_FOO, callback2);
const redisCallback = subClient.on.mock.calls[0][1];
redisCallback(CHANNEL_FOO, JSON.stringify(payload));
expect(callback).toHaveBeenCalledWith(payload);
expect(callback1).toHaveBeenCalledWith(payload);
expect(callback2).toHaveBeenCalledWith(payload);
});

it('should ignore message from unrelated channel', () => {
Expand Down

0 comments on commit 412d230

Please sign in to comment.