Skip to content

Commit 8998e53

Browse files
committed
test: dedupe cli route mock reads
1 parent 1cd736a commit 8998e53

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/cli/route.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ vi.mock("../runtime.js", () => ({
3434
},
3535
}));
3636

37+
function firstConfigReadyCall() {
38+
return ensureConfigReadyMock.mock.calls[0]?.[0] as
39+
| { runtime?: unknown; commandPath?: unknown }
40+
| undefined;
41+
}
42+
3743
describe("tryRouteCli", () => {
3844
let tryRouteCli: typeof import("./route.js").tryRouteCli;
3945
// Capture the same loggingState reference that route.js uses.
@@ -88,9 +94,7 @@ describe("tryRouteCli", () => {
8894
await expect(tryRouteCli(["node", "openclaw", "status"])).resolves.toBe(true);
8995

9096
expect(ensureConfigReadyMock).toHaveBeenCalledTimes(1);
91-
const configReadyCall = ensureConfigReadyMock.mock.calls.at(0)?.[0] as
92-
| { runtime?: unknown; commandPath?: unknown }
93-
| undefined;
97+
const configReadyCall = firstConfigReadyCall();
9498
expect(typeof configReadyCall?.runtime).toBe("object");
9599
expect(configReadyCall?.commandPath).toEqual(["status"]);
96100
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledWith({
@@ -161,9 +165,7 @@ describe("tryRouteCli", () => {
161165
["node", "openclaw", "--log-level", "debug", "status"],
162166
);
163167
expect(ensureConfigReadyMock).toHaveBeenCalledTimes(1);
164-
const configReadyCall = ensureConfigReadyMock.mock.calls.at(0)?.[0] as
165-
| { runtime?: unknown; commandPath?: unknown }
166-
| undefined;
168+
const configReadyCall = firstConfigReadyCall();
167169
expect(typeof configReadyCall?.runtime).toBe("object");
168170
expect(configReadyCall?.commandPath).toEqual(["status"]);
169171
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledWith({

0 commit comments

Comments
 (0)