diff --git a/clients/ts/signalr/tests/HubConnection.test.ts b/clients/ts/signalr/tests/HubConnection.test.ts index c3ff32e224..f7b5e0b6a1 100644 --- a/clients/ts/signalr/tests/HubConnection.test.ts +++ b/clients/ts/signalr/tests/HubConnection.test.ts @@ -900,21 +900,16 @@ describe("HubConnection", () => { const connection = new TestConnection(); const hubConnection = createHubConnection(connection); try { - hubConnection.serverTimeoutInMilliseconds = 100; + hubConnection.serverTimeoutInMilliseconds = 200; const p = new PromiseSource(); hubConnection.onclose((e) => p.resolve(e)); await hubConnection.start(); - await connection.receive({ type: MessageType.Ping }); - await delay(50); - await connection.receive({ type: MessageType.Ping }); - await delay(50); - await connection.receive({ type: MessageType.Ping }); - await delay(50); - await connection.receive({ type: MessageType.Ping }); - await delay(50); + for (let i = 0; i < 6; i++) { + await pingAndWait(connection); + } connection.stop(); @@ -930,7 +925,7 @@ describe("HubConnection", () => { const connection = new TestConnection(); const hubConnection = createHubConnection(connection); try { - hubConnection.serverTimeoutInMilliseconds = 100; + hubConnection.serverTimeoutInMilliseconds = 200; const p = new PromiseSource(); hubConnection.onclose((e) => p.resolve(e)); @@ -941,12 +936,9 @@ describe("HubConnection", () => { await hubConnection.start(); - await connection.receive({ type: MessageType.Ping }); - await delay(50); - await connection.receive({ type: MessageType.Ping }); - await delay(50); - await connection.receive({ type: MessageType.Ping }); - await delay(50); + for (let i = 0; i < 6; i++) { + await pingAndWait(connection); + } connection.stop(); @@ -979,6 +971,11 @@ describe("HubConnection", () => { }); }); +async function pingAndWait(connection: TestConnection): Promise { + await connection.receive({ type: MessageType.Ping }); + await delay(50); +} + class TestConnection implements IConnection { public readonly features: any = {};