summaryrefslogtreecommitdiff
path: root/cli/tests/unit/websocket_test.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-03-15 22:09:09 +0530
committerGitHub <noreply@github.com>2023-03-15 22:09:09 +0530
commit3a46a89e34aab3bea9f555ef6c80af33a7bc2194 (patch)
tree0ed10f82b54d2730af57d86272ed05729ad21c74 /cli/tests/unit/websocket_test.ts
parent5c505316b3205f7e354baff35839f522846143c2 (diff)
chore: add test for ws ping/pong (#18204)
This commit adds test for https://github.com/denoland/deno/issues/17761 which was fixed by https://github.com/denoland/deno/pull/17762. Verified that test fails on Deno 1.30.1
Diffstat (limited to 'cli/tests/unit/websocket_test.ts')
-rw-r--r--cli/tests/unit/websocket_test.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/cli/tests/unit/websocket_test.ts b/cli/tests/unit/websocket_test.ts
index b0379fac9..6737edc11 100644
--- a/cli/tests/unit/websocket_test.ts
+++ b/cli/tests/unit/websocket_test.ts
@@ -19,3 +19,20 @@ Deno.test(async function websocketConstructorTakeURLObjectAsParameter() {
};
await promise;
});
+
+// https://github.com/denoland/deno/pull/17762
+// https://github.com/denoland/deno/issues/17761
+Deno.test(async function websocketPingPong() {
+ const promise = deferred();
+ const ws = new WebSocket("ws://localhost:4245/");
+ assertEquals(ws.url, "ws://localhost:4245/");
+ ws.onerror = () => fail();
+ ws.onmessage = (e) => {
+ ws.send(e.data);
+ };
+ ws.onclose = () => {
+ promise.resolve();
+ };
+ await promise;
+ ws.close();
+});