























@@ -66,6 +66,18 @@ const workspaceConfig = {
6666},
6767} as OpenClawConfig;
686869+function firstMockArg(
70+mock: { mock: { calls: readonly unknown[][] } },
71+label: string,
72+): Record<string, unknown> {
73+const [call] = mock.mock.calls;
74+if (!call) {
75+throw new Error(`expected ${label} call`);
76+}
77+const [arg] = call;
78+return requireRecord(arg);
79+}
80+6981async function withSandbox(test: (sandboxDir: string) => Promise<void>) {
7082const sandboxDir = await fs.mkdtemp(path.join(os.tmpdir(), "msg-sandbox-"));
7183try {
@@ -277,7 +289,7 @@ describe("runMessageAction media behavior", () => {
277289});
278290279291expect(result.kind).toBe("send");
280-const sendArgs = requireRecord(channelResolutionMocks.executeSendAction.mock.calls[0]?.[0]);
292+const sendArgs = firstMockArg(channelResolutionMocks.executeSendAction, "executeSendAction");
281293expect(sendArgs.asVoice).toBe(true);
282294});
283295@@ -645,7 +657,7 @@ describe("runMessageAction media behavior", () => {
645657646658expect(result.kind).toBe("action");
647659expect(handleActionMock).toHaveBeenCalledTimes(1);
648-const handlerParams = handleActionMock.mock.calls[0]?.[0] as Record<string, unknown>;
660+const handlerParams = firstMockArg(handleActionMock, "handleAction");
649661expect(handlerParams.buffer).toBe(Buffer.from("hello").toString("base64"));
650662expect(handlerParams.filename).toBe("pic.png");
651663expect(handlerParams.contentType).toBe("image/png");
@@ -702,7 +714,7 @@ describe("runMessageAction media behavior", () => {
702714});
703715704716expect(handleActionMock).toHaveBeenCalledTimes(1);
705-const handlerParams = handleActionMock.mock.calls[0]?.[0] as Record<string, unknown>;
717+const handlerParams = firstMockArg(handleActionMock, "handleAction");
706718expect(handlerParams.caption).toBeUndefined();
707719expect(handlerParams.message).toBe("look at this");
708720});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。