| 87 | }; |
| 88 | |
| 89 | export function renderWithAuth( |
| 90 | element: JSX.Element, |
| 91 | { |
| 92 | path = "/", |
| 93 | route = "/", |
| 94 | extraRoutes = [], |
| 95 | nonAuthenticatedRoutes = [], |
| 96 | mockAuthProviders = {}, |
| 97 | children, |
| 98 | }: RenderWithAuthOptions = {}, |
| 99 | ) { |
| 100 | const routes: RouteObject[] = [ |
| 101 | { |
| 102 | element: <RequireAuth {...mockAuthProviders} />, |
| 103 | children: [{ path, element, children }, ...extraRoutes], |
| 104 | }, |
| 105 | ...nonAuthenticatedRoutes, |
| 106 | ]; |
| 107 | |
| 108 | const renderResult = renderWithRouter( |
| 109 | createMemoryRouter(routes, { initialEntries: [route] }), |
| 110 | ); |
| 111 | |
| 112 | return { |
| 113 | ...renderResult, |
| 114 | user: MockUserOwner, |
| 115 | }; |
| 116 | } |
| 117 | |
| 118 | export function renderWithTemplateSettingsLayout( |
| 119 | element: JSX.Element, |