























@@ -80,7 +80,17 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
8080function requireSendOptions(
8181mockedSend: ReturnType<typeof vi.mocked<(typeof import("./send.js"))["sendMessageZalouser"]>>,
8282): Record<string, unknown> {
83-return requireRecord(mockedSend.mock.calls[0]?.[2], "Zalouser send options");
83+return requireRecord(requireSendCall(mockedSend)[2], "Zalouser send options");
84+}
85+86+function requireSendCall(
87+mockedSend: ReturnType<typeof vi.mocked<(typeof import("./send.js"))["sendMessageZalouser"]>>,
88+): unknown[] {
89+const [call] = mockedSend.mock.calls as unknown[][];
90+if (!call) {
91+throw new Error("expected Zalouser send call");
92+}
93+return call;
8494}
85958696describe("zalouserPlugin outbound sendPayload", () => {
@@ -109,8 +119,9 @@ describe("zalouserPlugin outbound sendPayload", () => {
109119});
110120111121expect(mockedSend).toHaveBeenCalledOnce();
112-expect(mockedSend.mock.calls[0]?.[0]).toBe("1471383327500481391");
113-expect(mockedSend.mock.calls[0]?.[1]).toBe("hello group");
122+const sendCall = requireSendCall(mockedSend);
123+expect(sendCall[0]).toBe("1471383327500481391");
124+expect(sendCall[1]).toBe("hello group");
114125const options = requireSendOptions(mockedSend);
115126expect(options.isGroup).toBe(true);
116127expect(options.textMode).toBe("markdown");
@@ -128,8 +139,9 @@ describe("zalouserPlugin outbound sendPayload", () => {
128139});
129140130141expect(mockedSend).toHaveBeenCalledOnce();
131-expect(mockedSend.mock.calls[0]?.[0]).toBe("987654321");
132-expect(mockedSend.mock.calls[0]?.[1]).toBe("hello");
142+const sendCall = requireSendCall(mockedSend);
143+expect(sendCall[0]).toBe("987654321");
144+expect(sendCall[1]).toBe("hello");
133145const options = requireSendOptions(mockedSend);
134146expect(options.isGroup).toBe(false);
135147expect(options.textMode).toBe("markdown");
@@ -147,8 +159,9 @@ describe("zalouserPlugin outbound sendPayload", () => {
147159});
148160149161expect(mockedSend).toHaveBeenCalledOnce();
150-expect(mockedSend.mock.calls[0]?.[0]).toBe("g-1471383327500481391");
151-expect(mockedSend.mock.calls[0]?.[1]).toBe("hello native group");
162+const sendCall = requireSendCall(mockedSend);
163+expect(sendCall[0]).toBe("g-1471383327500481391");
164+expect(sendCall[1]).toBe("hello native group");
152165const options = requireSendOptions(mockedSend);
153166expect(options.isGroup).toBe(true);
154167expect(options.textMode).toBe("markdown");
@@ -167,8 +180,9 @@ describe("zalouserPlugin outbound sendPayload", () => {
167180});
168181169182expect(mockedSend).toHaveBeenCalledTimes(1);
170-expect(mockedSend.mock.calls[0]?.[0]).toBe("987654321");
171-expect(mockedSend.mock.calls[0]?.[1]).toBe(text);
183+const sendCall = requireSendCall(mockedSend);
184+expect(sendCall[0]).toBe("987654321");
185+expect(sendCall[1]).toBe(text);
172186const options = requireSendOptions(mockedSend);
173187expect(options.isGroup).toBe(false);
174188expect(options.textMode).toBe("markdown");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。