diff options
Diffstat (limited to 'cli/tests/websocket_test.ts')
-rw-r--r-- | cli/tests/websocket_test.ts | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/cli/tests/websocket_test.ts b/cli/tests/websocket_test.ts index 0a91ac308..51876dc59 100644 --- a/cli/tests/websocket_test.ts +++ b/cli/tests/websocket_test.ts @@ -3,9 +3,9 @@ import { assert, assertEquals, assertThrows, - createResolvable, fail, -} from "./unit/test_util.ts"; +} from "../../std/testing/asserts.ts"; +import { deferred } from "../../std/async/deferred.ts"; Deno.test("invalid scheme", () => { assertThrows(() => new WebSocket("foo://localhost:4242")); @@ -21,7 +21,7 @@ Deno.test("duplicate protocols", () => { }); Deno.test("invalid server", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:2121"); let err = false; ws.onerror = (): void => { @@ -39,7 +39,7 @@ Deno.test("invalid server", async () => { }); Deno.test("connect & close", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.onerror = (): void => fail(); ws.onopen = (): void => { @@ -52,7 +52,7 @@ Deno.test("connect & close", async () => { }); Deno.test("connect & abort", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.close(); let err = false; @@ -71,7 +71,7 @@ Deno.test("connect & abort", async () => { }); Deno.test("connect & close custom valid code", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.onerror = (): void => fail(); ws.onopen = (): void => ws.close(1000); @@ -82,7 +82,7 @@ Deno.test("connect & close custom valid code", async () => { }); Deno.test("connect & close custom invalid code", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.onerror = (): void => fail(); ws.onopen = (): void => { @@ -96,7 +96,7 @@ Deno.test("connect & close custom invalid code", async () => { }); Deno.test("connect & close custom valid reason", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.onerror = (): void => fail(); ws.onopen = (): void => ws.close(1000, "foo"); @@ -107,7 +107,7 @@ Deno.test("connect & close custom valid reason", async () => { }); Deno.test("connect & close custom invalid reason", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.onerror = (): void => fail(); ws.onopen = (): void => { @@ -121,7 +121,7 @@ Deno.test("connect & close custom invalid reason", async () => { }); Deno.test("echo string", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.onerror = (): void => fail(); ws.onopen = (): void => ws.send("foo"); @@ -136,8 +136,8 @@ Deno.test("echo string", async () => { }); Deno.test("echo string tls", async () => { - const promise1 = createResolvable(); - const promise2 = createResolvable(); + const promise1 = deferred(); + const promise2 = deferred(); const ws = new WebSocket("wss://localhost:4243"); ws.onerror = (): void => fail(); ws.onopen = (): void => ws.send("foo"); @@ -154,7 +154,7 @@ Deno.test("echo string tls", async () => { }); Deno.test("websocket error", async () => { - const promise1 = createResolvable(); + const promise1 = deferred(); const ws = new WebSocket("wss://localhost:4242"); ws.onopen = () => fail(); ws.onerror = (err): void => { @@ -166,7 +166,7 @@ Deno.test("websocket error", async () => { }); Deno.test("echo blob with binaryType blob", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); const blob = new Blob(["foo"]); ws.onerror = (): void => fail(); @@ -186,7 +186,7 @@ Deno.test("echo blob with binaryType blob", async () => { }); Deno.test("echo blob with binaryType arraybuffer", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.binaryType = "arraybuffer"; const blob = new Blob(["foo"]); @@ -205,7 +205,7 @@ Deno.test("echo blob with binaryType arraybuffer", async () => { }); Deno.test("echo uint8array with binaryType blob", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); const uint = new Uint8Array([102, 111, 111]); ws.onerror = (): void => fail(); @@ -223,7 +223,7 @@ Deno.test("echo uint8array with binaryType blob", async () => { }); Deno.test("echo uint8array with binaryType arraybuffer", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.binaryType = "arraybuffer"; const uint = new Uint8Array([102, 111, 111]); @@ -240,7 +240,7 @@ Deno.test("echo uint8array with binaryType arraybuffer", async () => { }); Deno.test("echo arraybuffer with binaryType blob", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); const buffer = new ArrayBuffer(3); ws.onerror = (): void => fail(); @@ -258,7 +258,7 @@ Deno.test("echo arraybuffer with binaryType blob", async () => { }); Deno.test("echo arraybuffer with binaryType arraybuffer", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); ws.binaryType = "arraybuffer"; const buffer = new ArrayBuffer(3); @@ -275,7 +275,7 @@ Deno.test("echo arraybuffer with binaryType arraybuffer", async () => { }); Deno.test("Event Handlers order", async () => { - const promise = createResolvable(); + const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); const arr: number[] = []; ws.onerror = (): void => fail(); |