























@@ -161,12 +161,11 @@ describe("discord native /status", () => {
161161162162expect(runtimeModuleMocks.resolveDirectStatusReplyForSession).toHaveBeenCalledTimes(1);
163163expect(runtimeModuleMocks.dispatchReplyWithDispatcher).not.toHaveBeenCalled();
164-expect(interaction.followUp).toHaveBeenCalledWith(
165-expect.objectContaining({
166-content: "status reply",
167-ephemeral: true,
168-}),
169-);
164+expect(interaction.followUp).toHaveBeenCalledTimes(1);
165+expect(interaction.followUp.mock.calls[0]?.[0]).toStrictEqual({
166+content: "status reply",
167+ephemeral: true,
168+});
170169expect(interaction.reply).not.toHaveBeenCalled();
171170});
172171@@ -193,12 +192,11 @@ describe("discord native /status", () => {
193192194193expect(runtimeModuleMocks.resolveDirectStatusReplyForSession).toHaveBeenCalledTimes(1);
195194expect(executePluginCommand).not.toHaveBeenCalled();
196-expect(interaction.followUp).toHaveBeenCalledWith(
197-expect.objectContaining({
198-content: "status reply",
199-ephemeral: true,
200-}),
201-);
195+expect(interaction.followUp).toHaveBeenCalledTimes(1);
196+expect(interaction.followUp.mock.calls[0]?.[0]).toStrictEqual({
197+content: "status reply",
198+ephemeral: true,
199+});
202200});
203201204202it("keeps every direct status chunk ephemeral", async () => {
@@ -213,11 +211,7 @@ describe("discord native /status", () => {
213211214212expect(interaction.followUp.mock.calls.length).toBeGreaterThan(1);
215213for (const [payload] of interaction.followUp.mock.calls) {
216-expect(payload).toEqual(
217-expect.objectContaining({
218-ephemeral: true,
219-}),
220-);
214+expect((payload as { ephemeral?: boolean }).ephemeral).toBe(true);
221215}
222216});
223217@@ -232,22 +226,20 @@ describe("discord native /status", () => {
232226233227await (command as { run: (interaction: unknown) => Promise<void> }).run(interaction as unknown);
234228235-expect(runtimeModuleMocks.loadWebMedia).toHaveBeenCalledWith("https://example.com/status.png", {
236-localRoots: expect.any(Array),
237-});
238-expect(interaction.followUp.mock.calls.length).toBeGreaterThan(1);
239-expect(interaction.followUp.mock.calls[0]?.[0]).toEqual(
240-expect.objectContaining({
241-ephemeral: true,
242-files: expect.arrayContaining([expect.objectContaining({ name: "status.png" })]),
243-}),
229+expect(runtimeModuleMocks.loadWebMedia).toHaveBeenCalledTimes(1);
230+const [mediaUrl, mediaOptions] = runtimeModuleMocks.loadWebMedia.mock.calls[0] ?? [];
231+expect(mediaUrl).toBe("https://example.com/status.png");
232+expect(Array.isArray((mediaOptions as { localRoots?: unknown } | undefined)?.localRoots)).toBe(
233+true,
244234);
235+expect(interaction.followUp.mock.calls.length).toBeGreaterThan(1);
236+const firstPayload = interaction.followUp.mock.calls[0]?.[0] as
237+| { ephemeral?: boolean; files?: Array<{ name?: string; data?: unknown }> }
238+| undefined;
239+expect(firstPayload?.ephemeral).toBe(true);
240+expect(firstPayload?.files?.map((file) => file.name)).toEqual(["status.png"]);
245241for (const [payload] of interaction.followUp.mock.calls) {
246-expect(payload).toEqual(
247-expect.objectContaining({
248-ephemeral: true,
249-}),
250-);
242+expect((payload as { ephemeral?: boolean }).ephemeral).toBe(true);
251243}
252244expect(interaction.reply).not.toHaveBeenCalled();
253245});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。