test(cli): avoid brittle mock call indexing in json-mode checks

This commit is contained in:
Altay
2026-02-23 12:38:19 +03:00
committed by Peter Steinberger
parent 9e4a366ee6
commit 67b98139b9
2 changed files with 4 additions and 13 deletions

View File

@@ -239,10 +239,6 @@ describe("registerPreActionHooks", () => {
processArgv: ["node", "openclaw", "config", "set", "gateway.auth.mode", "{bad", "--json"],
});
const firstCall = ensureConfigReadyMock.mock.calls[0]?.[0] as
| { suppressDoctorStdout?: boolean }
| undefined;
expect(firstCall?.suppressDoctorStdout).toBeUndefined();
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
runtime: runtimeMock,
commandPath: ["config", "set"],

View File

@@ -64,14 +64,9 @@ describe("tryRouteCli", () => {
it("does not pass suppressDoctorStdout for routed non-json commands", async () => {
await expect(tryRouteCli(["node", "openclaw", "status"])).resolves.toBe(true);
expect(ensureConfigReadyMock).toHaveBeenCalledWith(
expect.objectContaining({
commandPath: ["status"],
}),
);
const firstCall = ensureConfigReadyMock.mock.calls[0]?.[0] as
| { suppressDoctorStdout?: boolean }
| undefined;
expect(firstCall?.suppressDoctorStdout).toBeUndefined();
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
runtime: expect.any(Object),
commandPath: ["status"],
});
});
});