Skip to content

Commit 9dff3d9

Browse files
Fix SignalR TS unit test that was hitting the network (#35557)
1 parent 1c929ce commit 9dff3d9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/SignalR/clients/ts/signalr/tests/HttpConnection.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ describe("HttpConnection", () => {
213213
await VerifyLogger.run(async (loggerImpl) => {
214214
let negotiateCount: number = 0;
215215
const options: IHttpConnectionOptions = {
216-
WebSocket: false,
216+
WebSocket: TestWebSocket,
217217
...commonOptions,
218218
httpClient: new TestHttpClient()
219219
.on("POST", () => {
@@ -227,8 +227,16 @@ describe("HttpConnection", () => {
227227
transport: HttpTransportType.WebSockets,
228228
} as IHttpConnectionOptions;
229229

230+
TestWebSocket.webSocketSet = new PromiseSource();
231+
230232
const connection = new HttpConnection("http://tempuri.org", options);
231-
await expect(connection.start(TransferFormat.Text))
233+
const startPromise = connection.start(TransferFormat.Text);
234+
235+
await TestWebSocket.webSocketSet;
236+
await TestWebSocket.webSocket.closeSet;
237+
TestWebSocket.webSocket.onclose(new TestEvent());
238+
239+
await expect(startPromise)
232240
.rejects
233241
.toThrow("Unable to connect to the server with any of the available transports. Error: WebSockets failed: Error: WebSocket failed to connect. " +
234242
"The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, " +

0 commit comments

Comments
 (0)