import * as React from 'react'; import * as ReactRouterDom from 'react-router-dom'; import { Form } from '@patternfly/react-core'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { RenderOptions, render } from '@testing-library/react'; import { FormikValues, Formik } from 'formik'; import { NuqsTestingAdapter } from 'nuqs/adapters/testing'; import * as NamespaceUtils from '../shared/providers/Namespace/namespace-context'; import { createTestQueryClient } from './mock-react-query'; export const formikRenderer = ( element: React.ReactElement, initialValues?: FormikValues, options?: Omit, ) => { const client = createTestQueryClient(); return render(element, { wrapper: ({ children }) => ( {}}> {({ handleSubmit }) =>
{children}
}
), ...options, }); }; export const namespaceRenderer = ( element: React.ReactElement, namespace: string, contextValues?: Partial, options?: Omit, ) => render(element, { wrapper: ({ children }) => ( {children} ), ...options, }); export function renderWithQueryClientAndRouter( ui: React.ReactElement, client?: QueryClient, renderOptions?: Omit, ) { const queryClient = client ?? createTestQueryClient(); function Wrapper({ children }: { children: React.ReactNode }) { return ( {children} ); } return render(ui, { wrapper: Wrapper, ...renderOptions }); } export const WithTestNamespaceContext = (children: React.ReactNode, data?: Partial) => (): React.ReactElement => ( {children} );