mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const { createAcpxRuntimeServiceMock, tryDispatchAcpReplyHookMock } = vi.hoisted(() => ({
|
|
createAcpxRuntimeServiceMock: vi.fn(),
|
|
tryDispatchAcpReplyHookMock: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("./register.runtime.js", () => ({
|
|
createAcpxRuntimeService: createAcpxRuntimeServiceMock,
|
|
}));
|
|
|
|
vi.mock("./runtime-api.js", () => ({
|
|
tryDispatchAcpReplyHook: tryDispatchAcpReplyHookMock,
|
|
}));
|
|
|
|
import plugin from "./index.js";
|
|
|
|
describe("acpx plugin", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("registers the runtime service and reply_dispatch hook", () => {
|
|
const service = { id: "acpx-service", start: vi.fn() };
|
|
createAcpxRuntimeServiceMock.mockReturnValue(service);
|
|
|
|
const api = {
|
|
pluginConfig: { stateDir: "/tmp/acpx" },
|
|
registerService: vi.fn(),
|
|
on: vi.fn(),
|
|
};
|
|
|
|
plugin.register(api as never);
|
|
|
|
expect(createAcpxRuntimeServiceMock).toHaveBeenCalledWith({
|
|
pluginConfig: api.pluginConfig,
|
|
});
|
|
expect(api.registerService).toHaveBeenCalledWith(service);
|
|
expect(api.on).toHaveBeenCalledWith("reply_dispatch", tryDispatchAcpReplyHookMock);
|
|
});
|
|
});
|