mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
1090ed59b7
Co-authored-by: Pablo F.G <pablo.fernandez@prowler.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Alan Buscaglia <gentlemanprogramming@gmail.com>
26 lines
765 B
TypeScript
26 lines
765 B
TypeScript
import type { ComponentType, PropsWithChildren, ReactElement } from "react";
|
|
import { render as vitestRender } from "vitest-browser-react";
|
|
|
|
const TestProviders = ({ children }: PropsWithChildren) => <>{children}</>;
|
|
|
|
type RenderOptions = Parameters<typeof vitestRender>[1];
|
|
|
|
export function render(ui: ReactElement, options?: RenderOptions) {
|
|
const userWrapper = options?.wrapper as
|
|
| ComponentType<PropsWithChildren>
|
|
| undefined;
|
|
|
|
const Wrapper = userWrapper
|
|
? ({ children }: PropsWithChildren) => {
|
|
const Inner = userWrapper;
|
|
return (
|
|
<TestProviders>
|
|
<Inner>{children}</Inner>
|
|
</TestProviders>
|
|
);
|
|
}
|
|
: TestProviders;
|
|
|
|
return vitestRender(ui, { ...options, wrapper: Wrapper });
|
|
}
|