Increase TS HubConnection timeout in tests for slow build environments (#2328)

This commit is contained in:
James Newton-King 2018-05-22 09:24:33 +12:00 committed by GitHub
parent b1194f67e7
commit a699b61ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 16 deletions

View File

@ -900,21 +900,16 @@ describe("HubConnection", () => {
const connection = new TestConnection(); const connection = new TestConnection();
const hubConnection = createHubConnection(connection); const hubConnection = createHubConnection(connection);
try { try {
hubConnection.serverTimeoutInMilliseconds = 100; hubConnection.serverTimeoutInMilliseconds = 200;
const p = new PromiseSource<Error>(); const p = new PromiseSource<Error>();
hubConnection.onclose((e) => p.resolve(e)); hubConnection.onclose((e) => p.resolve(e));
await hubConnection.start(); await hubConnection.start();
await connection.receive({ type: MessageType.Ping }); for (let i = 0; i < 6; i++) {
await delay(50); await pingAndWait(connection);
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);
connection.stop(); connection.stop();
@ -930,7 +925,7 @@ describe("HubConnection", () => {
const connection = new TestConnection(); const connection = new TestConnection();
const hubConnection = createHubConnection(connection); const hubConnection = createHubConnection(connection);
try { try {
hubConnection.serverTimeoutInMilliseconds = 100; hubConnection.serverTimeoutInMilliseconds = 200;
const p = new PromiseSource<Error>(); const p = new PromiseSource<Error>();
hubConnection.onclose((e) => p.resolve(e)); hubConnection.onclose((e) => p.resolve(e));
@ -941,12 +936,9 @@ describe("HubConnection", () => {
await hubConnection.start(); await hubConnection.start();
await connection.receive({ type: MessageType.Ping }); for (let i = 0; i < 6; i++) {
await delay(50); await pingAndWait(connection);
await connection.receive({ type: MessageType.Ping }); }
await delay(50);
await connection.receive({ type: MessageType.Ping });
await delay(50);
connection.stop(); connection.stop();
@ -979,6 +971,11 @@ describe("HubConnection", () => {
}); });
}); });
async function pingAndWait(connection: TestConnection): Promise<void> {
await connection.receive({ type: MessageType.Ping });
await delay(50);
}
class TestConnection implements IConnection { class TestConnection implements IConnection {
public readonly features: any = {}; public readonly features: any = {};