From 0f6acf275370cae09ffb3f6950a3926424f3b024 Mon Sep 17 00:00:00 2001 From: Oliver Lenehan Date: Sat, 14 Mar 2020 12:40:13 +1100 Subject: fix(std): Use Deno.errors where possible. (#4356) --- std/ws/test.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'std/ws/test.ts') diff --git a/std/ws/test.ts b/std/ws/test.ts index f6c7319c1..e0050bcf4 100644 --- a/std/ws/test.ts +++ b/std/ws/test.ts @@ -14,8 +14,7 @@ import { readFrame, unmask, writeFrame, - createWebSocket, - SocketClosedError + createWebSocket } from "./mod.ts"; import { encode, decode } from "../strings/mod.ts"; import Writer = Deno.Writer; @@ -331,7 +330,7 @@ test("[ws] createSecKeyHasCorrectLength", () => { assertEquals(atob(secKey).length, 16); }); -test("[ws] WebSocket should throw SocketClosedError when peer closed connection without close frame", async () => { +test("[ws] WebSocket should throw `Deno.errors.ConnectionReset` when peer closed connection without close frame", async () => { const buf = new Buffer(); const eofReader: Deno.Reader = { async read(_: Uint8Array): Promise { @@ -341,12 +340,15 @@ test("[ws] WebSocket should throw SocketClosedError when peer closed connection const conn = dummyConn(eofReader, buf); const sock = createWebSocket({ conn }); sock.closeForce(); - await assertThrowsAsync(() => sock.send("hello"), SocketClosedError); - await assertThrowsAsync(() => sock.ping(), SocketClosedError); - await assertThrowsAsync(() => sock.close(0), SocketClosedError); + await assertThrowsAsync( + () => sock.send("hello"), + Deno.errors.ConnectionReset + ); + await assertThrowsAsync(() => sock.ping(), Deno.errors.ConnectionReset); + await assertThrowsAsync(() => sock.close(0), Deno.errors.ConnectionReset); }); -test("[ws] WebSocket shouldn't throw UnexpectedEOFError on recive()", async () => { +test("[ws] WebSocket shouldn't throw `Deno.errors.UnexpectedEof` on recive()", async () => { const buf = new Buffer(); const eofReader: Deno.Reader = { async read(_: Uint8Array): Promise { @@ -382,8 +384,8 @@ test("[ws] WebSocket should reject sending promise when connection reset forcely sock.closeForce(); assertEquals(sock.isClosed, true); const [a, b, c] = await p; - assert(a instanceof SocketClosedError); - assert(b instanceof SocketClosedError); - assert(c instanceof SocketClosedError); + assert(a instanceof Deno.errors.ConnectionReset); + assert(b instanceof Deno.errors.ConnectionReset); + assert(c instanceof Deno.errors.ConnectionReset); clearTimeout(timer); }); -- cgit v1.2.3