test: dedupe update cli mock reads

This commit is contained in:
Peter Steinberger
2026-05-12 23:57:58 +01:00
parent d3099ff0de
commit 1cd736afd2

View File

@@ -34,6 +34,10 @@ vi.mock("../runtime.js", () => ({
defaultRuntime: mocks.defaultRuntime,
}));
function firstCallOptions(mock: { mock: { calls: unknown[][] } }) {
return mock.mock.calls[0]?.[0];
}
describe("update cli option collisions", () => {
beforeEach(() => {
updateCommand.mockClear();
@@ -52,7 +56,7 @@ describe("update cli option collisions", () => {
argv: ["update", "status", "--json", "--timeout", "9"],
assert: () => {
expect(updateStatusCommand).toHaveBeenCalledTimes(1);
const [opts] = updateStatusCommand.mock.calls.at(0) ?? [];
const opts = firstCallOptions(updateStatusCommand);
expect((opts as { json?: boolean; timeout?: string } | undefined)?.json).toBe(true);
expect((opts as { json?: boolean; timeout?: string } | undefined)?.timeout).toBe("9");
},
@@ -62,7 +66,7 @@ describe("update cli option collisions", () => {
argv: ["update", "wizard", "--timeout", "13"],
assert: () => {
expect(updateWizardCommand).toHaveBeenCalledTimes(1);
const [opts] = updateWizardCommand.mock.calls.at(0) ?? [];
const opts = firstCallOptions(updateWizardCommand);
expect((opts as { timeout?: string } | undefined)?.timeout).toBe("13");
},
},