From 3a46a89e34aab3bea9f555ef6c80af33a7bc2194 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 15 Mar 2023 22:09:09 +0530 Subject: 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 --- cli/tests/unit/websocket_test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cli/tests') 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(); +}); -- cgit v1.2.3