Skip to content

Commit

Permalink
test: reconnecting event
Browse files Browse the repository at this point in the history
  • Loading branch information
uki00a committed Dec 10, 2024
1 parent d9210ea commit 91d80db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/reconnect_test.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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 () => {
Expand Down

0 comments on commit 91d80db

Please sign in to comment.