mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-01 04:11:03 +00:00
Merged via squash.
Prepared head SHA: ad1dee32eb
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { createTestPluginApi } from "../../test/helpers/plugins/plugin-api.js";
|
|
|
|
const cliMocks = vi.hoisted(() => ({
|
|
registerMatrixCli: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("./src/cli.js", async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import("./src/cli.js")>();
|
|
return {
|
|
...actual,
|
|
registerMatrixCli: cliMocks.registerMatrixCli,
|
|
};
|
|
});
|
|
|
|
import matrixPlugin from "./index.js";
|
|
|
|
describe("matrix plugin", () => {
|
|
it("registers matrix CLI through a descriptor-backed lazy registrar", async () => {
|
|
const registerCli = vi.fn();
|
|
const api = createTestPluginApi({
|
|
id: "matrix",
|
|
name: "Matrix",
|
|
source: "test",
|
|
config: {},
|
|
runtime: {} as never,
|
|
registerCli,
|
|
});
|
|
|
|
matrixPlugin.register(api);
|
|
|
|
const registrar = registerCli.mock.calls[0]?.[0];
|
|
expect(registerCli).toHaveBeenCalledWith(expect.any(Function), {
|
|
descriptors: [
|
|
{
|
|
name: "matrix",
|
|
description: "Manage Matrix accounts, verification, devices, and profile state",
|
|
hasSubcommands: true,
|
|
},
|
|
],
|
|
});
|
|
expect(typeof registrar).toBe("function");
|
|
expect(cliMocks.registerMatrixCli).not.toHaveBeenCalled();
|
|
|
|
const program = { command: vi.fn() };
|
|
const result = registrar?.({ program } as never);
|
|
|
|
await result;
|
|
expect(cliMocks.registerMatrixCli).toHaveBeenCalledWith({ program });
|
|
});
|
|
});
|