



















@@ -60,6 +60,14 @@ describe("acp cli option collisions", () => {
6060expect(defaultRuntime.exit).toHaveBeenCalledWith(1);
6161}
626263+function requireFirstMockArg(mock: { mock: { calls: ReadonlyArray<ReadonlyArray<unknown>> } }) {
64+const call = mock.mock.calls[0];
65+if (!call) {
66+throw new Error("expected mock to have at least one call");
67+}
68+return call[0];
69+}
70+6371beforeEach(() => {
6472runAcpClientInteractive.mockClear();
6573serveAcpGateway.mockClear();
@@ -77,9 +85,7 @@ describe("acp cli option collisions", () => {
7785});
78867987expect(runAcpClientInteractive).toHaveBeenCalledTimes(1);
80-const clientOptions = runAcpClientInteractive.mock.calls.at(0)?.[0] as
81-| { verbose?: boolean }
82-| undefined;
88+const clientOptions = requireFirstMockArg(runAcpClientInteractive) as { verbose?: boolean };
8389expect(clientOptions?.verbose).toBe(true);
8490});
8591@@ -99,9 +105,10 @@ describe("acp cli option collisions", () => {
99105);
100106101107expect(serveAcpGateway).toHaveBeenCalledTimes(1);
102-const gatewayOptions = serveAcpGateway.mock.calls.at(0)?.[0] as
103-| { gatewayPassword?: string; gatewayToken?: string }
104-| undefined;
108+const gatewayOptions = requireFirstMockArg(serveAcpGateway) as {
109+gatewayPassword?: string;
110+gatewayToken?: string;
111+};
105112expect(gatewayOptions?.gatewayToken).toBe("tok_file");
106113expect(gatewayOptions?.gatewayPassword).toBe("pw_file"); // pragma: allowlist secret
107114});
@@ -150,9 +157,7 @@ describe("acp cli option collisions", () => {
150157});
151158152159expect(serveAcpGateway).toHaveBeenCalledTimes(1);
153-const gatewayOptions = serveAcpGateway.mock.calls.at(0)?.[0] as
154-| { gatewayToken?: string }
155-| undefined;
160+const gatewayOptions = requireFirstMockArg(serveAcpGateway) as { gatewayToken?: string };
156161expect(gatewayOptions?.gatewayToken).toBe("tok_file");
157162});
158163此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。