

























@@ -1,4 +1,4 @@
1-import { describe, expect, it, vi } from "vitest";
1+import { afterEach, describe, expect, it, vi } from "vitest";
22import {
33gracefulStopSlackApp,
44publishSlackConnectedStatus,
@@ -36,28 +36,34 @@ class FakeEmitter {
3636}
37373838describe("slack socket reconnect helpers", () => {
39+afterEach(() => {
40+vi.restoreAllMocks();
41+});
42+3943it("marks socket mode healthy without seeding event liveness on connect", () => {
4044const setStatus = vi.fn();
45+vi.spyOn(Date, "now").mockReturnValue(1_711_406_400_000);
41464247publishSlackConnectedStatus(setStatus);
43484449expect(setStatus).toHaveBeenCalledTimes(1);
4550expect(setStatus).toHaveBeenCalledWith(
4651expect.objectContaining({
4752connected: true,
48-lastConnectedAt: expect.any(Number),
53+lastConnectedAt: 1_711_406_400_000,
4954healthState: "healthy",
5055lastError: null,
5156}),
5257);
5358expect(setStatus).not.toHaveBeenCalledWith(
54-expect.objectContaining({ lastEventAt: expect.any(Number) }),
59+expect.objectContaining({ lastEventAt: 1_711_406_400_000 }),
5560);
5661});
57625863it("marks socket mode disconnected when an error closes the socket", () => {
5964const setStatus = vi.fn();
6065const err = new Error("dns down");
66+vi.spyOn(Date, "now").mockReturnValue(1_711_406_401_000);
61676268publishSlackDisconnectedStatus(setStatus, err);
6369@@ -66,7 +72,7 @@ describe("slack socket reconnect helpers", () => {
6672connected: false,
6773healthState: "disconnected",
6874lastDisconnect: {
69-at: expect.any(Number),
75+at: 1_711_406_401_000,
7076error: "dns down",
7177},
7278lastError: "dns down",
@@ -75,6 +81,7 @@ describe("slack socket reconnect helpers", () => {
75817682it("marks socket mode disconnected without error when the socket closes cleanly", () => {
7783const setStatus = vi.fn();
84+vi.spyOn(Date, "now").mockReturnValue(1_711_406_402_000);
78857986publishSlackDisconnectedStatus(setStatus);
8087@@ -83,7 +90,7 @@ describe("slack socket reconnect helpers", () => {
8390connected: false,
8491healthState: "disconnected",
8592lastDisconnect: {
86-at: expect.any(Number),
93+at: 1_711_406_402_000,
8794},
8895lastError: null,
8996});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。