diff options
author | Leo K <crowlkats@toaxl.com> | 2021-08-05 13:08:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-05 13:08:58 +0200 |
commit | 3f0cf9619fce71a8898c495501df4bdb0e07e735 (patch) | |
tree | 1b8af2c832f8344f9a39f55326d576eab63f447f /cli/tests/websocket_test.ts | |
parent | 299c7cfe54cb184e0d0c18b00a154c953b433ebf (diff) |
refactor(cli/tests): remove unnecessary void return types (#11577)
Diffstat (limited to 'cli/tests/websocket_test.ts')
-rw-r--r-- | cli/tests/websocket_test.ts | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/cli/tests/websocket_test.ts b/cli/tests/websocket_test.ts index 8a7fc812c..7d62679fe 100644 --- a/cli/tests/websocket_test.ts +++ b/cli/tests/websocket_test.ts @@ -24,28 +24,28 @@ Deno.test("invalid server", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:2121"); let err = false; - ws.onerror = (): void => { + ws.onerror = () => { err = true; }; - ws.onclose = (): void => { + ws.onclose = () => { if (err) { promise.resolve(); } else { fail(); } }; - ws.onopen = (): void => fail(); + ws.onopen = () => fail(); await promise; }); Deno.test("connect & close", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); - ws.onerror = (): void => fail(); - ws.onopen = (): void => { + ws.onerror = () => fail(); + ws.onopen = () => { ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -56,26 +56,26 @@ Deno.test("connect & abort", async () => { const ws = new WebSocket("ws://localhost:4242"); ws.close(); let err = false; - ws.onerror = (): void => { + ws.onerror = () => { err = true; }; - ws.onclose = (): void => { + ws.onclose = () => { if (err) { promise.resolve(); } else { fail(); } }; - ws.onopen = (): void => fail(); + ws.onopen = () => fail(); await promise; }); Deno.test("connect & close custom valid code", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.close(1000); - ws.onclose = (): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.close(1000); + ws.onclose = () => { promise.resolve(); }; await promise; @@ -84,12 +84,12 @@ Deno.test("connect & close custom valid code", async () => { Deno.test("connect & close custom invalid code", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); - ws.onerror = (): void => fail(); - ws.onopen = (): void => { + ws.onerror = () => fail(); + ws.onopen = () => { assertThrows(() => ws.close(1001)); ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -98,9 +98,9 @@ Deno.test("connect & close custom invalid code", async () => { Deno.test("connect & close custom valid reason", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.close(1000, "foo"); - ws.onclose = (): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.close(1000, "foo"); + ws.onclose = () => { promise.resolve(); }; await promise; @@ -109,12 +109,12 @@ Deno.test("connect & close custom valid reason", async () => { Deno.test("connect & close custom invalid reason", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); - ws.onerror = (): void => fail(); - ws.onopen = (): void => { + ws.onerror = () => fail(); + ws.onopen = () => { assertThrows(() => ws.close(1000, "".padEnd(124, "o"))); ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -123,13 +123,13 @@ Deno.test("connect & close custom invalid reason", async () => { Deno.test("echo string", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.send("foo"); - ws.onmessage = (e): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.send("foo"); + ws.onmessage = (e) => { assertEquals(e.data, "foo"); ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -139,14 +139,14 @@ Deno.test("echo string tls", async () => { const promise1 = deferred(); const promise2 = deferred(); const ws = new WebSocket("wss://localhost:4243"); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.send("foo"); - ws.onmessage = (e): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.send("foo"); + ws.onmessage = (e) => { assertEquals(e.data, "foo"); ws.close(); promise1.resolve(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise2.resolve(); }; await promise1; @@ -157,7 +157,7 @@ Deno.test("websocket error", async () => { const promise1 = deferred(); const ws = new WebSocket("wss://localhost:4242"); ws.onopen = () => fail(); - ws.onerror = (err): void => { + ws.onerror = (err) => { assert(err instanceof ErrorEvent); // Error message got changed because we don't use warp in test_util @@ -171,9 +171,9 @@ Deno.test("echo blob with binaryType blob", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); const blob = new Blob(["foo"]); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.send(blob); - ws.onmessage = (e): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.send(blob); + ws.onmessage = (e) => { e.data.text().then((actual: string) => { blob.text().then((expected) => { assertEquals(actual, expected); @@ -181,7 +181,7 @@ Deno.test("echo blob with binaryType blob", async () => { }); ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -192,15 +192,15 @@ Deno.test("echo blob with binaryType arraybuffer", async () => { const ws = new WebSocket("ws://localhost:4242"); ws.binaryType = "arraybuffer"; const blob = new Blob(["foo"]); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.send(blob); - ws.onmessage = (e): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.send(blob); + ws.onmessage = (e) => { blob.arrayBuffer().then((expected) => { assertEquals(e.data, expected); }); ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -210,15 +210,15 @@ Deno.test("echo uint8array with binaryType blob", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); const uint = new Uint8Array([102, 111, 111]); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.send(uint); - ws.onmessage = (e): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.send(uint); + ws.onmessage = (e) => { e.data.arrayBuffer().then((actual: ArrayBuffer) => { assertEquals(actual, uint.buffer); }); ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -229,13 +229,13 @@ Deno.test("echo uint8array with binaryType arraybuffer", async () => { const ws = new WebSocket("ws://localhost:4242"); ws.binaryType = "arraybuffer"; const uint = new Uint8Array([102, 111, 111]); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.send(uint); - ws.onmessage = (e): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.send(uint); + ws.onmessage = (e) => { assertEquals(e.data, uint.buffer); ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -245,15 +245,15 @@ Deno.test("echo arraybuffer with binaryType blob", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); const buffer = new ArrayBuffer(3); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.send(buffer); - ws.onmessage = (e): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.send(buffer); + ws.onmessage = (e) => { e.data.arrayBuffer().then((actual: ArrayBuffer) => { assertEquals(actual, buffer); }); ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -264,13 +264,13 @@ Deno.test("echo arraybuffer with binaryType arraybuffer", async () => { const ws = new WebSocket("ws://localhost:4242"); ws.binaryType = "arraybuffer"; const buffer = new ArrayBuffer(3); - ws.onerror = (): void => fail(); - ws.onopen = (): void => ws.send(buffer); - ws.onmessage = (e): void => { + ws.onerror = () => fail(); + ws.onopen = () => ws.send(buffer); + ws.onmessage = (e) => { assertEquals(e.data, buffer); ws.close(); }; - ws.onclose = (): void => { + ws.onclose = () => { promise.resolve(); }; await promise; @@ -280,7 +280,7 @@ Deno.test("Event Handlers order", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4242"); const arr: number[] = []; - ws.onerror = (): void => fail(); + ws.onerror = () => fail(); ws.addEventListener("message", () => arr.push(1)); ws.onmessage = () => fail(); ws.addEventListener("message", () => { @@ -289,8 +289,8 @@ Deno.test("Event Handlers order", async () => { assertEquals(arr, [1, 2, 3]); }); ws.onmessage = () => arr.push(2); - ws.onopen = (): void => ws.send("Echo"); - ws.onclose = (): void => { + ws.onopen = () => ws.send("Echo"); + ws.onclose = () => { promise.resolve(); }; await promise; @@ -299,8 +299,8 @@ Deno.test("Event Handlers order", async () => { Deno.test("Close without frame", async () => { const promise = deferred(); const ws = new WebSocket("ws://localhost:4244"); - ws.onerror = (): void => fail(); - ws.onclose = (e): void => { + ws.onerror = () => fail(); + ws.onclose = (e) => { assertEquals(e.code, 1005); promise.resolve(); }; |