Files
fusion/packages/dashboard/app/test/mockLucide.ts
Fusion 07c552f823 feat(FN-3044): add canonical mock helpers and migrate representative test s
This merge introduces canonical mock helper modules across the dashboard and engine packages, and migrates representative test suites to use them for consistency. The changes add four new mock helpers (`mockApi.ts`, `mockLucide.ts`, `mockCore.ts`, `mockCoreEngine.ts`) and harden the API mock proxy's

Fusion-Task-Id: FN-3044
2026-05-01 00:33:17 -07:00

31 lines
1.1 KiB
TypeScript

/**
* Canonical lucide-react mock helper for dashboard app tests.
*
* Add newly used icons here first before creating per-suite lucide export lists.
*/
import React from "react";
type AnyModule = Record<string, unknown>;
function icon(name: string) {
return function MockIcon(props: Record<string, unknown>) {
return React.createElement("span", { "data-testid": `icon-${name}`, ...props });
};
}
export async function createLucideMock(importActual: () => Promise<AnyModule>): Promise<AnyModule> {
const actual = await importActual();
return new Proxy({ ...actual }, {
get(target, prop, receiver) {
if (typeof prop !== "string") return Reflect.get(target, prop, receiver);
if (["then", "catch", "finally"].includes(prop)) return undefined;
if (Reflect.has(target, prop)) return Reflect.get(target, prop, receiver);
const generated = icon(
prop.replace(/[A-Z]/g, (m, idx) => (idx === 0 ? m.toLowerCase() : `-${m.toLowerCase()}`)),
);
(target as AnyModule)[prop] = generated;
return generated;
},
});
}