From 4badbe8ee3cb6b1c113de5b39cd3314c40fa1185 Mon Sep 17 00:00:00 2001 From: Gus Narea Date: Wed, 18 Aug 2021 22:39:14 +0100 Subject: [PATCH] fix --- src/backingServices/natsStreaming.spec.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/backingServices/natsStreaming.spec.ts b/src/backingServices/natsStreaming.spec.ts index e830bd675..a6a710736 100644 --- a/src/backingServices/natsStreaming.spec.ts +++ b/src/backingServices/natsStreaming.spec.ts @@ -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 () => {