From 91d80db36eb7934b577620394b3dd2b4b2a08b8a Mon Sep 17 00:00:00 2001 From: uki00a Date: Tue, 10 Dec 2024 22:49:19 +0900 Subject: [PATCH] test: `reconnecting` event --- tests/reconnect_test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/reconnect_test.ts b/tests/reconnect_test.ts index 8f6b907c..4a9f4278 100644 --- a/tests/reconnect_test.ts +++ b/tests/reconnect_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../deps/std/assert.ts"; +import { assertEquals, assertInstanceOf } from "../deps/std/assert.ts"; import { beforeAll, describe, it } from "../deps/std/testing.ts"; import { newClient, nextPort, startRedis, stopRedis } from "./test_util.ts"; @@ -14,9 +14,15 @@ describe("reconnect", () => { assertEquals(await client.ping(), "PONG"); await stopRedis(server); server = await startRedis({ port }); + let reconnectingFired = 0; + client.addEventListener("reconnecting", (e) => { + reconnectingFired++; + assertInstanceOf(e, CustomEvent); + }); assertEquals(await client.ping(), "PONG"); client.close(); await stopRedis(server); + assertEquals(reconnectingFired, 1); }); it("auto reconnect, with db spec", async () => {