mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 19:21:08 +00:00
test(infra): update loaded outbound target mock
This commit is contained in:
@@ -3,30 +3,20 @@ import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { tryResolveLoadedOutboundTarget } from "./targets-loaded.js";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
getChannelPlugin: vi.fn(),
|
||||
getActivePluginRegistry: vi.fn(),
|
||||
getActivePluginChannelRegistry: vi.fn(),
|
||||
getLoadedChannelPlugin: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../../channels/plugins/index.js", () => ({
|
||||
getChannelPlugin: mocks.getChannelPlugin,
|
||||
}));
|
||||
|
||||
vi.mock("../../plugins/runtime.js", () => ({
|
||||
getActivePluginRegistry: mocks.getActivePluginRegistry,
|
||||
getActivePluginChannelRegistry: mocks.getActivePluginChannelRegistry,
|
||||
getLoadedChannelPlugin: mocks.getLoadedChannelPlugin,
|
||||
}));
|
||||
|
||||
describe("tryResolveLoadedOutboundTarget", () => {
|
||||
beforeEach(() => {
|
||||
mocks.getChannelPlugin.mockReset();
|
||||
mocks.getActivePluginRegistry.mockReset();
|
||||
mocks.getActivePluginChannelRegistry.mockReset();
|
||||
mocks.getLoadedChannelPlugin.mockReset();
|
||||
});
|
||||
|
||||
it("returns undefined when no loaded plugin exists", () => {
|
||||
mocks.getChannelPlugin.mockReturnValue(undefined);
|
||||
mocks.getActivePluginRegistry.mockReturnValue(null);
|
||||
mocks.getLoadedChannelPlugin.mockReturnValue(undefined);
|
||||
|
||||
expect(tryResolveLoadedOutboundTarget({ channel: "telegram", to: "123" })).toBeUndefined();
|
||||
});
|
||||
@@ -35,7 +25,7 @@ describe("tryResolveLoadedOutboundTarget", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: { telegram: { defaultTo: "123456789" } },
|
||||
};
|
||||
mocks.getChannelPlugin.mockReturnValue({
|
||||
mocks.getLoadedChannelPlugin.mockReturnValue({
|
||||
id: "telegram",
|
||||
meta: { label: "Telegram" },
|
||||
capabilities: {},
|
||||
|
||||
Reference in New Issue
Block a user