File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
src/SignalR/clients/ts/signalr/tests Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -1273,18 +1273,22 @@ describe("HubConnection", () => {
1273
1273
const connection = new TestConnection ( ) ;
1274
1274
const hubConnection = createHubConnection ( connection , logger ) ;
1275
1275
try {
1276
- hubConnection . serverTimeoutInMilliseconds = 400 ;
1276
+ const timeoutInMilliseconds = 400 ;
1277
+ hubConnection . serverTimeoutInMilliseconds = timeoutInMilliseconds ;
1277
1278
1278
1279
const p = new PromiseSource < Error > ( ) ;
1279
1280
hubConnection . onclose ( ( e ) => p . resolve ( e ) ) ;
1280
1281
1281
1282
await hubConnection . start ( ) ;
1282
1283
1283
- for ( let i = 0 ; i < 12 ; i ++ ) {
1284
- await pingAndWait ( connection ) ;
1285
- }
1284
+ const pingInterval = setInterval ( async ( ) => {
1285
+ await connection . receive ( { type : MessageType . Ping } ) ;
1286
+ } , 10 ) ;
1287
+
1288
+ await delayUntil ( timeoutInMilliseconds * 2 ) ;
1286
1289
1287
1290
await connection . stop ( ) ;
1291
+ clearInterval ( pingInterval ) ;
1288
1292
1289
1293
const error = await p . promise ;
1290
1294
@@ -1318,11 +1322,6 @@ describe("HubConnection", () => {
1318
1322
} ) ;
1319
1323
} ) ;
1320
1324
1321
- async function pingAndWait ( connection : TestConnection ) : Promise < void > {
1322
- await connection . receive ( { type : MessageType . Ping } ) ;
1323
- await delayUntil ( 50 ) ;
1324
- }
1325
-
1326
1325
class TestProtocol implements IHubProtocol {
1327
1326
public readonly name : string = "TestProtocol" ;
1328
1327
public readonly version : number = 1 ;
You can’t perform that action at this time.
0 commit comments