The merge consolidates mock helpers across packages by creating a new shared `mockCoreEngine.ts` in the CLI package and strengthening the core/engine helpers, then migrating both CLI command tests and the dashboard's `AgentsView` tests to use the canonical helpers. It also publishes SSE architecture Fusion-Task-Id: FN-3053
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import {
|
|
createCliCoreMock,
|
|
createCliEngineMock,
|
|
resetCliCoreEngineMockState,
|
|
} from "./mockCoreEngine";
|
|
|
|
describe("cli test mock helpers", () => {
|
|
it("creates stable fallback functions for missing callable exports", async () => {
|
|
const module = await createCliCoreMock(async () => ({ known: vi.fn() }));
|
|
|
|
const first = module.missingThing as ReturnType<typeof vi.fn>;
|
|
const second = module.missingThing as ReturnType<typeof vi.fn>;
|
|
expect(first).toBe(second);
|
|
|
|
first("x");
|
|
expect(first).toHaveBeenCalledWith("x");
|
|
|
|
resetCliCoreEngineMockState();
|
|
expect(first).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("keeps real non-function exports while allowing callable overrides", async () => {
|
|
const module = await createCliEngineMock(
|
|
async () => ({ VERSION: "1.0.0", factory: () => "real" }),
|
|
{},
|
|
{ factory: vi.fn().mockReturnValue("mocked") },
|
|
);
|
|
|
|
expect(module.VERSION).toBe("1.0.0");
|
|
expect((module.factory as () => string)()).toBe("mocked");
|
|
});
|
|
});
|