summaryrefslogtreecommitdiff
path: root/std/ws/test.ts
diff options
context:
space:
mode:
authorOliver Lenehan <sunsetkookaburra+github@outlook.com.au>2020-03-14 12:40:13 +1100
committerGitHub <noreply@github.com>2020-03-13 21:40:13 -0400
commit0f6acf275370cae09ffb3f6950a3926424f3b024 (patch)
treee77a2115394f36dcbd899fd8f2d5496ca7bde625 /std/ws/test.ts
parentaab1acaed163f91aa5e89b079c5312336abb2088 (diff)
fix(std): Use Deno.errors where possible. (#4356)
Diffstat (limited to 'std/ws/test.ts')
-rw-r--r--std/ws/test.ts22
1 files changed, 12 insertions, 10 deletions
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<number | Deno.EOF> {
@@ -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<number | Deno.EOF> {
@@ -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);
});