MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / createProviderWrapper

Function createProviderWrapper

console/src/test/utils.tsx:174–217  ·  view source on GitHub ↗
({
  initializeState,
  router,
  store,
  queryClient: queryClientOverride,
}: ProviderWrapperProps = {})

Source from the content-addressed store, hash-verified

172 * MemoryRouter.
173 */
174export const createProviderWrapper = async ({
175 initializeState,
176 router,
177 store,
178 queryClient: queryClientOverride,
179}: ProviderWrapperProps = {}) => {
180 router = router ?? { type: "BROWSER_ROUTER" };
181
182 let Router = BrowserRouter;
183 let routerProps = {};
184
185 if (router.type === "MEMORY_ROUTER") {
186 Router = MemoryRouter;
187 routerProps = {
188 initialEntries: router.initialRouterEntries,
189 };
190 }
191
192 const queryClient = queryClientOverride ?? getQueryClient();
193
194 store ||= getStore();
195 await initializeState?.(store);
196
197 return function ({ children }: React.PropsWithChildren) {
198 return (
199 <JotaiProvider store={store}>
200 <ThemeProvider theme={lightTheme}>
201 <EnvironmentProvider>
202 <React.Suspense fallback="provider-wrapper-suspense-fallback">
203 <QueryClientProvider client={queryClient}>
204 <Router {...routerProps}>
205 <SentryRoutes>
206 <Route index path="*" element={children} />
207 </SentryRoutes>
208 </Router>
209 </QueryClientProvider>
210 </React.Suspense>
211 <ToastProvider />
212 </EnvironmentProvider>
213 </ThemeProvider>
214 </JotaiProvider>
215 );
216 };
217};
218
219export function buildCluster(
220 overrides: Partial<ClusterWithOwnership> = {},

Calls 3

getQueryClientFunction · 0.90
getStoreFunction · 0.90
initializeStateFunction · 0.85

Tested by 1

renderComponentFunction · 0.72