

























@@ -28,6 +28,14 @@ vi.mock("./plugin-entry.handlers.runtime.js", () => runtimeMocks);
2828vi.mock("./runtime-setter-api.js", () => ({ setMatrixRuntime: runtimeMocks.setMatrixRuntime }));
2929vi.mock("./src/matrix/subagent-hooks.js", () => runtimeMocks);
303031+function requireFirstCliRegistration(mock: ReturnType<typeof vi.fn>) {
32+const [call] = mock.mock.calls;
33+if (!call || typeof call[0] !== "function") {
34+throw new Error("expected Matrix CLI registration");
35+}
36+return call as [(ctx: unknown) => unknown, unknown];
37+}
38+3139describe("matrix plugin", () => {
3240it("registers matrix CLI through a descriptor-backed lazy registrar", async () => {
3341const registerCli = vi.fn();
@@ -45,10 +53,10 @@ describe("matrix plugin", () => {
45534654registerMatrixCliMetadata(api);
475548-const registrar = registerCli.mock.calls[0]?.[0];
4956expect(registerCli).toHaveBeenCalledTimes(1);
57+const [registrar, options] = requireFirstCliRegistration(registerCli);
5058expect(typeof registrar).toBe("function");
51-expect(registerCli.mock.calls[0]?.[1]).toEqual({
59+expect(options).toEqual({
5260descriptors: [
5361{
5462name: "matrix",
@@ -57,9 +65,6 @@ describe("matrix plugin", () => {
5765},
5866],
5967});
60-if (!registrar) {
61-throw new Error("expected Matrix CLI registrar to be registered");
62-}
6368expect(cliMocks.registerMatrixCli).not.toHaveBeenCalled();
64696570const program = { command: vi.fn() };
@@ -98,8 +103,9 @@ describe("matrix plugin", () => {
98103entry.register(api);
99104100105expect(registerCli).toHaveBeenCalledTimes(1);
101-expect(typeof registerCli.mock.calls[0]?.[0]).toBe("function");
102-expect(registerCli.mock.calls[0]?.[1]).toEqual({
106+const [registrar, options] = requireFirstCliRegistration(registerCli);
107+expect(typeof registrar).toBe("function");
108+expect(options).toEqual({
103109descriptors: [
104110{
105111name: "matrix",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。