Files
fusion/packages/cli/src/test/mockCoreEngine.test.ts
Fusion fc3864ebd4 feat(FN-3053): consolidate mock helpers across CLI, dashboard, and engine p
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
2026-05-01 05:04:05 -07:00

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");
});
});