Cover websocket disconnect rejection in adapter tests
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
2cb6ed9615
commit
b5a830b328
1 file changed
+13
@@ -177,4 +177,17 @@ describe("wsNativeApi", () => {
|
||||
|
||||
await expect(request).rejects.toThrow("boom");
|
||||
});
|
||||
|
||||
it("rejects pending requests when websocket disconnects", async () => {
|
||||
setWindowSearch("?ws=ws%3A%2F%2F127.0.0.1%3A4403");
|
||||
const { getOrCreateWsNativeApi } = await import("./wsNativeApi");
|
||||
const api = getOrCreateWsNativeApi();
|
||||
|
||||
const request = api.todos.list();
|
||||
const socket = MockWebSocket.instances[0];
|
||||
await waitForCondition(() => (socket?.sentMessages.length ?? 0) > 0);
|
||||
socket?.close();
|
||||
|
||||
await expect(request).rejects.toThrow("websocket disconnected");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user