

























@@ -96,6 +96,10 @@ function expectApprovalRuntime(
9696return runtime;
9797}
989899+function firstCallArg(mock: ReturnType<typeof vi.fn>): unknown {
100+return mock.mock.calls[0]?.[0];
101+}
102+99103describe("createChannelApprovalHandlerFromCapability", () => {
100104it("returns null when the capability does not expose a native runtime", async () => {
101105await expect(
@@ -154,7 +158,9 @@ describe("createChannelApprovalHandlerFromCapability", () => {
154158await approvalRuntime.stop();
155159156160expect(unbindPending).toHaveBeenCalledOnce();
157-const stopUnbind = unbindPending.mock.calls.at(0)?.[0];
161+const stopUnbind = firstCallArg(unbindPending) as
162+| { request?: unknown; approvalKind?: string }
163+| undefined;
158164expect(stopUnbind?.request).toBe(request);
159165expect(stopUnbind?.approvalKind).toBe("plugin");
160166});
@@ -183,7 +189,9 @@ describe("createChannelApprovalHandlerFromCapability", () => {
183189} as never);
184190185191expect(unbindPending).toHaveBeenCalledTimes(1);
186-const unbind = unbindPending.mock.calls.at(0)?.[0];
192+const unbind = firstCallArg(unbindPending) as
193+| { entry?: unknown; binding?: unknown; request?: unknown }
194+| undefined;
187195expect(unbind?.entry).toEqual({ messageId: "1" });
188196expect(unbind?.binding).toEqual({ bindingId: "bound-1" });
189197expect(unbind?.request).toBe(request);
@@ -226,7 +234,8 @@ describe("createChannelApprovalHandlerFromCapability", () => {
226234227235expect(unbindPending).toHaveBeenCalledTimes(2);
228236expect(buildResolvedResult).toHaveBeenCalledTimes(1);
229-expect(buildResolvedResult.mock.calls.at(0)?.[0]?.entry).toEqual({ messageId: "2" });
237+const resolvedPayload = firstCallArg(buildResolvedResult) as { entry?: unknown } | undefined;
238+expect(resolvedPayload?.entry).toEqual({ messageId: "2" });
230239});
231240232241it("continues stop-time unbind cleanup when one binding throws", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。