























@@ -79,21 +79,33 @@ describe("sendFailureNotificationAnnounce", () => {
7979agentId: "main",
8080sessionKey: "cron:job-1:failure",
8181});
82-expect(mocks.deliverOutboundPayloads).toHaveBeenCalledWith(
83-expect.objectContaining({
84- cfg,
85-channel: "telegram",
86-to: "123",
87-accountId: "bot-a",
88-threadId: 42,
89-payloads: [{ text: "Cron failed" }],
90-session: { kind: "session" },
91-identity: { kind: "identity" },
92-bestEffort: false,
93-deps: { kind: "deps" },
94-abortSignal: expect.any(AbortSignal),
95-}),
96-);
82+expect(mocks.deliverOutboundPayloads).toHaveBeenCalledTimes(1);
83+const [deliveryRequest] = mocks.deliverOutboundPayloads.mock.calls[0] as [
84+{
85+abortSignal?: unknown;
86+accountId?: string;
87+bestEffort?: boolean;
88+cfg?: unknown;
89+channel?: string;
90+deps?: unknown;
91+identity?: unknown;
92+payloads?: unknown;
93+session?: unknown;
94+threadId?: number;
95+to?: string;
96+},
97+];
98+expect(deliveryRequest.cfg).toBe(cfg);
99+expect(deliveryRequest.channel).toBe("telegram");
100+expect(deliveryRequest.to).toBe("123");
101+expect(deliveryRequest.accountId).toBe("bot-a");
102+expect(deliveryRequest.threadId).toBe(42);
103+expect(deliveryRequest.payloads).toEqual([{ text: "Cron failed" }]);
104+expect(deliveryRequest.session).toEqual({ kind: "session" });
105+expect(deliveryRequest.identity).toEqual({ kind: "identity" });
106+expect(deliveryRequest.bestEffort).toBe(false);
107+expect(deliveryRequest.deps).toEqual({ kind: "deps" });
108+expect(deliveryRequest.abortSignal).toBeInstanceOf(AbortSignal);
97109});
9811099111it("uses sessionKey for delivery-target resolution and outbound context", async () => {
@@ -158,13 +170,14 @@ describe("sendFailureNotificationAnnounce", () => {
158170),
159171).resolves.toBeUndefined();
160172161-expect(mocks.warn).toHaveBeenCalledWith(
162-expect.objectContaining({
163-err: "send failed",
164-channel: "telegram",
165-to: "123",
166-}),
167-"cron: failure destination announce failed",
168-);
173+expect(mocks.warn).toHaveBeenCalledTimes(1);
174+const [warnMeta, warnMessage] = mocks.warn.mock.calls[0] as [
175+{ channel?: string; err?: string; to?: string },
176+string,
177+];
178+expect(warnMeta.err).toBe("send failed");
179+expect(warnMeta.channel).toBe("telegram");
180+expect(warnMeta.to).toBe("123");
181+expect(warnMessage).toBe("cron: failure destination announce failed");
169182});
170183});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。