mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:38:38 +00:00
test(agents): dedupe subagent registry test mocks
This commit is contained in:
15
src/agents/subagent-registry.mocks.shared.ts
Normal file
15
src/agents/subagent-registry.mocks.shared.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { vi } from "vitest";
|
||||||
|
|
||||||
|
const noop = () => {};
|
||||||
|
|
||||||
|
vi.mock("../gateway/call.js", () => ({
|
||||||
|
callGateway: vi.fn(async () => ({
|
||||||
|
status: "ok",
|
||||||
|
startedAt: 111,
|
||||||
|
endedAt: 222,
|
||||||
|
})),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("../infra/agent-events.js", () => ({
|
||||||
|
onAgentEvent: vi.fn(() => noop),
|
||||||
|
}));
|
||||||
@@ -1,18 +1,5 @@
|
|||||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import "./subagent-registry.mocks.shared.js";
|
||||||
const noop = () => {};
|
|
||||||
|
|
||||||
vi.mock("../gateway/call.js", () => ({
|
|
||||||
callGateway: vi.fn(async () => ({
|
|
||||||
status: "ok",
|
|
||||||
startedAt: 111,
|
|
||||||
endedAt: 222,
|
|
||||||
})),
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock("../infra/agent-events.js", () => ({
|
|
||||||
onAgentEvent: vi.fn(() => noop),
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock("../config/config.js", () => ({
|
vi.mock("../config/config.js", () => ({
|
||||||
loadConfig: vi.fn(() => ({
|
loadConfig: vi.fn(() => ({
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
|
|||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import "./subagent-registry.mocks.shared.js";
|
||||||
import { captureEnv } from "../test-utils/env.js";
|
import { captureEnv } from "../test-utils/env.js";
|
||||||
import {
|
import {
|
||||||
initSubagentRegistry,
|
initSubagentRegistry,
|
||||||
@@ -10,20 +11,6 @@ import {
|
|||||||
} from "./subagent-registry.js";
|
} from "./subagent-registry.js";
|
||||||
import { loadSubagentRegistryFromDisk } from "./subagent-registry.store.js";
|
import { loadSubagentRegistryFromDisk } from "./subagent-registry.store.js";
|
||||||
|
|
||||||
const noop = () => {};
|
|
||||||
|
|
||||||
vi.mock("../gateway/call.js", () => ({
|
|
||||||
callGateway: vi.fn(async () => ({
|
|
||||||
status: "ok",
|
|
||||||
startedAt: 111,
|
|
||||||
endedAt: 222,
|
|
||||||
})),
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock("../infra/agent-events.js", () => ({
|
|
||||||
onAgentEvent: vi.fn(() => noop),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const { announceSpy } = vi.hoisted(() => ({
|
const { announceSpy } = vi.hoisted(() => ({
|
||||||
announceSpy: vi.fn(async () => true),
|
announceSpy: vi.fn(async () => true),
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user