summaryrefslogtreecommitdiff
path: root/cli/tests/websocket_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/websocket_test.ts')
-rw-r--r--cli/tests/websocket_test.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/cli/tests/websocket_test.ts b/cli/tests/websocket_test.ts
index 93fddf446..0a91ac308 100644
--- a/cli/tests/websocket_test.ts
+++ b/cli/tests/websocket_test.ts
@@ -273,3 +273,23 @@ Deno.test("echo arraybuffer with binaryType arraybuffer", async () => {
};
await promise;
});
+
+Deno.test("Event Handlers order", async () => {
+ const promise = createResolvable();
+ const ws = new WebSocket("ws://localhost:4242");
+ const arr: number[] = [];
+ ws.onerror = (): void => fail();
+ ws.addEventListener("message", () => arr.push(1));
+ ws.onmessage = () => fail();
+ ws.addEventListener("message", () => {
+ arr.push(3);
+ ws.close();
+ assertEquals(arr, [1, 2, 3]);
+ });
+ ws.onmessage = () => arr.push(2);
+ ws.onopen = (): void => ws.send("Echo");
+ ws.onclose = (): void => {
+ promise.resolve();
+ };
+ await promise;
+});