
























@@ -10,6 +10,14 @@ vi.mock("../gateway/operator-approvals-client.js", () => ({
1010withOperatorApprovalsGatewayClient: hoisted.withOperatorApprovalsGatewayClient,
1111}));
121213+function requireFirstMockCall<T>(mock: { mock: { calls: T[][] } }, label: string): T[] {
14+const call = mock.mock.calls.at(0);
15+if (!call) {
16+throw new Error(`expected ${label} call`);
17+}
18+return call;
19+}
20+1321describe("resolveApprovalOverGateway", () => {
1422beforeEach(() => {
1523hoisted.clientRequest.mockReset().mockResolvedValue({ ok: true });
@@ -28,8 +36,10 @@ describe("resolveApprovalOverGateway", () => {
2836});
29373038expect(hoisted.withOperatorApprovalsGatewayClient).toHaveBeenCalledTimes(1);
31-const [gatewayClientOptions, gatewayClientRunner] =
32-hoisted.withOperatorApprovalsGatewayClient.mock.calls[0];
39+const [gatewayClientOptions, gatewayClientRunner] = requireFirstMockCall(
40+hoisted.withOperatorApprovalsGatewayClient,
41+"gateway client",
42+);
3343expect(gatewayClientOptions).toEqual({
3444config: { gateway: { auth: { token: "cfg-token" } } },
3545gatewayUrl: "ws://gateway.example.test",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。