mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
test: dedupe command helper mock reads
This commit is contained in:
@@ -369,7 +369,7 @@ describe("deliverAgentCommandResult", () => {
|
||||
|
||||
expect(runtime.log).toHaveBeenCalledTimes(1);
|
||||
expect(
|
||||
JSON.parse(String((runtime.log as ReturnType<typeof vi.fn>).mock.calls.at(0)?.[0])),
|
||||
JSON.parse(String((runtime.log as ReturnType<typeof vi.fn>).mock.calls[0]?.[0])),
|
||||
).toEqual({
|
||||
payloads: [
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
||||
}
|
||||
|
||||
function requireResolveCommandConfigParams(callIndex = 0): ResolveCommandConfigParams {
|
||||
const call = resolveCommandConfigWithSecretsMock.mock.calls.at(callIndex);
|
||||
const call = resolveCommandConfigWithSecretsMock.mock.calls[callIndex];
|
||||
if (!call) {
|
||||
throw new Error(`expected command config resolution call ${callIndex}`);
|
||||
}
|
||||
|
||||
@@ -639,7 +639,7 @@ describe("applyAuthChoice", () => {
|
||||
expect(promptMessages(mock)).toContain(expected);
|
||||
}
|
||||
function firstCallArg(mock: { mock: { calls: unknown[][] } }): unknown {
|
||||
const call = mock.mock.calls.at(0);
|
||||
const call = mock.mock.calls[0];
|
||||
if (!call) {
|
||||
throw new Error("Expected first mock call");
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ function makeRuntime(): RuntimeEnv {
|
||||
}
|
||||
|
||||
function promptModelAllowlistOptions(index = 0) {
|
||||
return mocks.promptModelAllowlist.mock.calls.at(index)?.at(0) as
|
||||
return mocks.promptModelAllowlist.mock.calls[index]?.[0] as
|
||||
| {
|
||||
allowedKeys?: string[];
|
||||
initialSelections?: string[];
|
||||
|
||||
@@ -307,7 +307,7 @@ describe("maybeRepairGatewayDaemon", () => {
|
||||
});
|
||||
|
||||
expect(readGatewayRestartHandoffSync).toHaveBeenCalledOnce();
|
||||
const [handoffEnv] = readGatewayRestartHandoffSync.mock.calls.at(0) as unknown as [
|
||||
const [handoffEnv] = readGatewayRestartHandoffSync.mock.calls[0] as unknown as [
|
||||
{ OPENCLAW_STATE_DIR?: string; OPENCLAW_CONFIG_PATH?: string },
|
||||
];
|
||||
expect(handoffEnv?.OPENCLAW_STATE_DIR).toBe("/tmp/openclaw-service");
|
||||
|
||||
@@ -202,7 +202,7 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
}
|
||||
|
||||
function callArg(mock: { mock: { calls: Array<Array<unknown>> } }, index: number, label: string) {
|
||||
const call = mock.mock.calls.at(index);
|
||||
const call = mock.mock.calls[index];
|
||||
if (!call) {
|
||||
throw new Error(`Expected mock call: ${label}`);
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ type MigrationSelectionPrompt = {
|
||||
};
|
||||
|
||||
function mockCall(source: MockCallSource, callIndex = 0): ReadonlyArray<unknown> {
|
||||
const call = source.mock.calls.at(callIndex);
|
||||
const call = source.mock.calls[callIndex];
|
||||
if (!call) {
|
||||
throw new Error(`Expected mock call ${callIndex}`);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
}
|
||||
|
||||
function mockArg(source: MockCallSource, callIndex: number, argIndex: number, label: string) {
|
||||
const call = source.mock.calls.at(callIndex);
|
||||
const call = source.mock.calls[callIndex];
|
||||
if (!call) {
|
||||
throw new Error(`expected mock call: ${label}`);
|
||||
}
|
||||
@@ -617,7 +617,7 @@ describe("promptDefaultModel", () => {
|
||||
expect(result.model).toBe("openai-codex/gpt-5.5-pro");
|
||||
expect(loadModelCatalog).toHaveBeenCalledOnce();
|
||||
expect(select).toHaveBeenCalledTimes(2);
|
||||
expect(select.mock.calls.at(1)?.[0]?.searchable).toBe(true);
|
||||
expect(select.mock.calls[1]?.[0]?.searchable).toBe(true);
|
||||
});
|
||||
|
||||
it("supports configuring vLLM during setup", async () => {
|
||||
|
||||
Reference in New Issue
Block a user