test: dedupe feishu doc mock reads · openclaw/openclaw@32103aa
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,6 +6,16 @@ const createFeishuClientMock = vi.fn((creds: { appId?: string } | undefined) =>
|
6 | 6 | __appId: creds?.appId, |
7 | 7 | })); |
8 | 8 | |
| 9 | +function feishuClientAppId(callIndex: number): string | undefined { |
| 10 | +const resolvedIndex = |
| 11 | +callIndex < 0 ? createFeishuClientMock.mock.calls.length + callIndex : callIndex; |
| 12 | +const call = createFeishuClientMock.mock.calls[resolvedIndex]; |
| 13 | +if (!call) { |
| 14 | +throw new Error(`expected createFeishuClient call ${callIndex}`); |
| 15 | +} |
| 16 | +return call[0]?.appId; |
| 17 | +} |
| 18 | + |
9 | 19 | vi.mock("./client.js", () => { |
10 | 20 | return { |
11 | 21 | createFeishuClient: (creds: { appId?: string } | undefined) => createFeishuClientMock(creds), |
@@ -63,8 +73,8 @@ describe("feishu_doc account selection", () => {
|
63 | 73 | await docToolB.execute("call-b", { action: "list_blocks", doc_token: "d" }); |
64 | 74 | |
65 | 75 | expect(createFeishuClientMock).toHaveBeenCalledTimes(2); |
66 | | -expect(createFeishuClientMock.mock.calls.at(0)?.[0]?.appId).toBe("app-a"); |
67 | | -expect(createFeishuClientMock.mock.calls.at(1)?.[0]?.appId).toBe("app-b"); |
| 76 | +expect(feishuClientAppId(0)).toBe("app-a"); |
| 77 | +expect(feishuClientAppId(1)).toBe("app-b"); |
68 | 78 | }); |
69 | 79 | |
70 | 80 | test("explicit accountId param overrides agentAccountId context", async () => { |
@@ -80,6 +90,6 @@ describe("feishu_doc account selection", () => {
|
80 | 90 | accountId: "a", |
81 | 91 | }); |
82 | 92 | |
83 | | -expect(createFeishuClientMock.mock.calls.at(-1)?.[0]?.appId).toBe("app-a"); |
| 93 | +expect(feishuClientAppId(-1)).toBe("app-a"); |
84 | 94 | }); |
85 | 95 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。