Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarea committed Aug 18, 2021
1 parent ccc2b23 commit 4badbe8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/backingServices/natsStreaming.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,17 @@ describe('NatsStreamingClient', () => {
);
});

test('Publishing should only be done once the connection has been established', async (done) => {
test('Publishing should only be done once the connection has been established', async () => {
const publisher = stubClient.makePublisher(STUB_CHANNEL);
setImmediate(() => {
// "connect" event was never emitted, so no message should've been published
expect(mockConnection.on).toBeCalledWith('connect', expect.any(Function));

expect(mockConnection.publish).not.toBeCalled();
await publisher([STUB_MESSAGE_1]);

done();
});
await new Promise(setImmediate);

await publisher([STUB_MESSAGE_1]);
// "connect" event was never emitted, so no message should've been published
expect(mockConnection.on).toBeCalledWith('connect', expect.any(Function));

expect(mockConnection.publish).not.toBeCalled();
});

test('Messages should be published to the specified channel', async () => {
Expand Down

0 comments on commit 4badbe8

Please sign in to comment.