From 85f041e3e10d8226d2e26de726ccbd63f5702311 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Wed, 9 Dec 2020 22:25:54 +0100 Subject: [PATCH] test: reconnect silently with promise --- src/tests/client.ts | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/tests/client.ts b/src/tests/client.ts index 21fb889a..1d1a2cdf 100644 --- a/src/tests/client.ts +++ b/src/tests/client.ts @@ -664,21 +664,30 @@ describe('reconnecting', () => { it('should reconnect silently after socket closes', async () => { const { url, ...server } = await startTServer(); - const sub = tsubscribe( - createClient({ - url, - retryAttempts: 1, - }), - { - query: 'subscription { ping }', - }, - ); + const client = createClient({ + url, + retryAttempts: 3, + retryWait: () => Promise.resolve(), + }); + const sub = tsubscribe(client, { + query: 'subscription { ping }', + }); + + await server.waitForClient((client) => { + client.close(); + }); + + // retried + await server.waitForClient((client) => { + client.close(); + }); + // once more await server.waitForClient((client) => { client.close(); }); - // tried again + // and once more await server.waitForClient((client) => { client.close(); });