test: dedupe gateway cli mock reads

This commit is contained in:
Peter Steinberger
2026-05-13 00:02:45 +01:00
parent 86c4482c58
commit f96cfeeb73

View File

@@ -122,6 +122,14 @@ vi.mock("./discover.js", () => ({
renderBeaconLines: () => [],
}));
function firstGatewayCall() {
return callGatewayCli.mock.calls[0] ?? [];
}
function firstGatewayStatusCall() {
return gatewayStatusCommand.mock.calls[0] ?? [];
}
describe("gateway register option collisions", () => {
let sharedProgram: Command = new Command();
@@ -146,7 +154,7 @@ describe("gateway register option collisions", () => {
argv: ["gateway", "call", "health", "--token", "tok_call", "--json"],
assert: () => {
expect(callGatewayCli).toHaveBeenCalledTimes(1);
const [method, opts, params] = callGatewayCli.mock.calls.at(0) ?? [];
const [method, opts, params] = firstGatewayCall();
expect(method).toBe("health");
expect((opts as { token?: string } | undefined)?.token).toBe("tok_call");
expect(params).toEqual({});
@@ -157,7 +165,7 @@ describe("gateway register option collisions", () => {
argv: ["gateway", "probe", "--token", "tok_probe", "--json"],
assert: () => {
expect(gatewayStatusCommand).toHaveBeenCalledTimes(1);
const [opts, runtime] = gatewayStatusCommand.mock.calls.at(0) ?? [];
const [opts, runtime] = firstGatewayStatusCall();
expect((opts as { token?: string } | undefined)?.token).toBe("tok_probe");
expect(runtime).toBe(defaultRuntime);
},