



















@@ -11,6 +11,17 @@ vi.mock("./client.js", () => ({
1111const { getMatrixDeviceHealth, listMatrixOwnDevices, pruneMatrixStaleGatewayDevices } =
1212await import("./devices.js");
131314+function expectResolvedActionClientCall(): void {
15+expect(withResolvedActionClientMock).toHaveBeenCalledTimes(1);
16+const call = withResolvedActionClientMock.mock.calls.at(0);
17+if (!call) {
18+throw new Error("Expected resolved action client call");
19+}
20+expect(call[0]).toEqual({ accountId: "poe" });
21+expect(call[1]).toBeTypeOf("function");
22+expect(withStartedActionClientMock).not.toHaveBeenCalled();
23+}
24+1425describe("matrix device actions", () => {
1526beforeEach(() => {
1627vi.clearAllMocks();
@@ -33,10 +44,7 @@ describe("matrix device actions", () => {
33443445const result = await listMatrixOwnDevices({ accountId: "poe" });
354636-expect(withResolvedActionClientMock).toHaveBeenCalledTimes(1);
37-expect(withResolvedActionClientMock.mock.calls[0]?.[0]).toEqual({ accountId: "poe" });
38-expect(withResolvedActionClientMock.mock.calls[0]?.[1]).toBeTypeOf("function");
39-expect(withStartedActionClientMock).not.toHaveBeenCalled();
47+expectResolvedActionClientCall();
4048expect(result).toEqual([
4149{
4250deviceId: "A7hWrQ70ea",
@@ -93,10 +101,7 @@ describe("matrix device actions", () => {
93101},
94102],
95103});
96-expect(withResolvedActionClientMock).toHaveBeenCalledTimes(1);
97-expect(withResolvedActionClientMock.mock.calls[0]?.[0]).toEqual({ accountId: "poe" });
98-expect(withResolvedActionClientMock.mock.calls[0]?.[1]).toBeTypeOf("function");
99-expect(withStartedActionClientMock).not.toHaveBeenCalled();
104+expectResolvedActionClientCall();
100105});
101106102107it("prunes stale OpenClaw-managed devices but preserves the current device", async () => {
@@ -210,9 +215,6 @@ describe("matrix device actions", () => {
210215},
211216],
212217});
213-expect(withResolvedActionClientMock).toHaveBeenCalledTimes(1);
214-expect(withResolvedActionClientMock.mock.calls[0]?.[0]).toEqual({ accountId: "poe" });
215-expect(withResolvedActionClientMock.mock.calls[0]?.[1]).toBeTypeOf("function");
216-expect(withStartedActionClientMock).not.toHaveBeenCalled();
218+expectResolvedActionClientCall();
217219});
218220});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。