diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2020-09-13 11:52:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-13 11:52:20 +0200 |
commit | daa780e2cf2bf606f78c686ac1416786bf85d107 (patch) | |
tree | 51b9517bb39d30943b610d58b1ea49233c0b1ac7 /cli/tests | |
parent | 82d0f7ec84ccf8652441b5de620e85180ce55fc0 (diff) |
fix(WebSocket): no panic on failed connect + handle promise rejection via error event (#7437)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/websocket_test.ts | 22 |
2 files changed, 25 insertions, 3 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 3c2154dff..44e56d246 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -403,7 +403,9 @@ fn fmt_stdin_error() { } // Warning: this test requires internet access. +// TODO(#7412): reenable. test is flaky #[test] +#[ignore] fn upgrade_in_tmpdir() { let temp_dir = TempDir::new().unwrap(); let exe_path = temp_dir.path().join("deno"); @@ -423,7 +425,9 @@ fn upgrade_in_tmpdir() { } // Warning: this test requires internet access. +// TODO(#7412): reenable. test is flaky #[test] +#[ignore] fn upgrade_with_space_in_path() { let temp_dir = tempfile::Builder::new() .prefix("directory with spaces") @@ -473,7 +477,9 @@ fn upgrade_with_version_in_tmpdir() { } // Warning: this test requires internet access. +// TODO(#7412): reenable. test is flaky #[test] +#[ignore] fn upgrade_with_out_in_tmpdir() { let temp_dir = TempDir::new().unwrap(); let exe_path = temp_dir.path().join("deno"); diff --git a/cli/tests/websocket_test.ts b/cli/tests/websocket_test.ts index 0fb9af951..93fddf446 100644 --- a/cli/tests/websocket_test.ts +++ b/cli/tests/websocket_test.ts @@ -1,5 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { + assert, assertEquals, assertThrows, createResolvable, @@ -135,18 +136,33 @@ Deno.test("echo string", async () => { }); Deno.test("echo string tls", async () => { - const promise = createResolvable(); + const promise1 = createResolvable(); + const promise2 = createResolvable(); const ws = new WebSocket("wss://localhost:4243"); ws.onerror = (): void => fail(); ws.onopen = (): void => ws.send("foo"); ws.onmessage = (e): void => { assertEquals(e.data, "foo"); ws.close(); + promise1.resolve(); }; ws.onclose = (): void => { - promise.resolve(); + promise2.resolve(); }; - await promise; + await promise1; + await promise2; +}); + +Deno.test("websocket error", async () => { + const promise1 = createResolvable(); + const ws = new WebSocket("wss://localhost:4242"); + ws.onopen = () => fail(); + ws.onerror = (err): void => { + assert(err instanceof ErrorEvent); + assertEquals(err.message, "InvalidData: received corrupt message"); + promise1.resolve(); + }; + await promise1; }); Deno.test("echo blob with binaryType blob", async () => { |