mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 00:31:24 +00:00
chore: Fix types in tests 10/N.
This commit is contained in:
@@ -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) ?? [];
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user