mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-27 17:11:46 +00:00
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { createTestPluginApi } from "../../test/helpers/plugins/plugin-api.js";
|
|
import type { OpenClawPluginApi } from "./api.js";
|
|
import plugin from "./index.js";
|
|
|
|
function createApi() {
|
|
const registerCli = vi.fn();
|
|
const registerTool = vi.fn();
|
|
const api = createTestPluginApi({
|
|
id: "memory-wiki",
|
|
name: "Memory Wiki",
|
|
source: "test",
|
|
config: {},
|
|
runtime: {} as OpenClawPluginApi["runtime"],
|
|
registerCli,
|
|
registerTool,
|
|
}) as OpenClawPluginApi;
|
|
return { api, registerCli, registerTool };
|
|
}
|
|
|
|
describe("memory-wiki plugin", () => {
|
|
it("registers the status tool and wiki cli surface", async () => {
|
|
const { api, registerCli, registerTool } = createApi();
|
|
|
|
await plugin.register(api);
|
|
|
|
expect(registerTool).toHaveBeenCalledTimes(3);
|
|
expect(registerTool.mock.calls.map((call) => call[1]?.name)).toEqual([
|
|
"wiki_status",
|
|
"wiki_search",
|
|
"wiki_get",
|
|
]);
|
|
expect(registerCli).toHaveBeenCalledTimes(1);
|
|
expect(registerCli.mock.calls[0]?.[1]).toMatchObject({
|
|
descriptors: [
|
|
expect.objectContaining({
|
|
name: "wiki",
|
|
hasSubcommands: true,
|
|
}),
|
|
],
|
|
});
|
|
});
|
|
});
|