chore: Fix types in tests 10/N.

This commit is contained in:
cpojer
2026-02-17 11:17:14 +09:00
parent 95f344e433
commit 058eb85762
5 changed files with 35 additions and 19 deletions

View File

@@ -245,7 +245,7 @@ describe("channels command", () => {
});
await channelsListCommand({ json: true, usage: false }, runtime);
const payload = JSON.parse(String(runtime.log.mock.calls[0]?.[0] ?? "{}")) as {
const payload = JSON.parse(runtime.log.mock.calls[0]?.[0] as string) as {
auth?: Array<{ id: string }>;
};
const ids = payload.auth?.map((entry) => entry.id) ?? [];

View File

@@ -1,9 +1,9 @@
import fsSync from "node:fs";
import type { OpenClawConfig } from "../config/config.js";
import { resolveAgentDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
import { resolveMemorySearchConfig } from "../agents/memory-search.js";
import { resolveApiKeyForProvider } from "../agents/model-auth.js";
import { formatCliCommand } from "../cli/command-format.js";
import type { OpenClawConfig } from "../config/config.js";
import { note } from "../terminal/note.js";
import { resolveUserPath } from "../utils.js";

View File

@@ -1,4 +1,5 @@
import { vi } from "vitest";
import type { RuntimeEnv } from "../runtime.js";
import type { MockFn } from "../test-utils/vitest-mock-fn.js";
export const baseConfigSnapshot = {
@@ -13,15 +14,18 @@ export const baseConfigSnapshot = {
};
export type TestRuntime = {
log: MockFn;
error: MockFn;
exit: MockFn;
log: MockFn<RuntimeEnv["log"]>;
error: MockFn<RuntimeEnv["error"]>;
exit: MockFn<RuntimeEnv["exit"]>;
};
export function createTestRuntime(): TestRuntime {
const log = vi.fn() as MockFn<RuntimeEnv["log"]>;
const error = vi.fn() as MockFn<RuntimeEnv["error"]>;
const exit = vi.fn((_: number) => undefined) as MockFn<RuntimeEnv["exit"]>;
return {
log: vi.fn(),
error: vi.fn(),
exit: vi.fn(),
log,
error,
exit,
};
}