From d07150db11cbd950b123fb6c8578ab5f0d74e770 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 2 Aug 2024 09:52:34 +0200 Subject: [PATCH] frontend: use RouterContextProvider instead of RouterProvider in tests --- frontend/src/test-utils/dummy-router.tsx | 0 frontend/src/test-utils/router.tsx | 16 +++------------- 2 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 frontend/src/test-utils/dummy-router.tsx diff --git a/frontend/src/test-utils/dummy-router.tsx b/frontend/src/test-utils/dummy-router.tsx deleted file mode 100644 index e69de29b..00000000 diff --git a/frontend/src/test-utils/router.tsx b/frontend/src/test-utils/router.tsx index 4cf13dbd..c25eeaba 100644 --- a/frontend/src/test-utils/router.tsx +++ b/frontend/src/test-utils/router.tsx @@ -13,7 +13,7 @@ // limitations under the License. import { - RouterProvider, + RouterContextProvider, createMemoryHistory, createRootRoute, createRoute, @@ -22,25 +22,15 @@ import { const rootRoute = createRootRoute(); const index = createRoute({ getParentRoute: () => rootRoute, path: "/" }); -rootRoute.addChildren([index]); const router = createRouter({ history: createMemoryHistory(), - routeTree: rootRoute, + routeTree: rootRoute.addChildren([index]), }); -const routerReady = router.load(); -// Because we also use this in the stories, we need to make sure we call this only in tests -if (import.meta.vitest) { - // Make sure the router is ready before running any tests - import("vitest").then(({ beforeAll }) => - beforeAll(async () => await routerReady), - ); -} - export const DummyRouter: React.FC = ({ children, }) => ( /** @ts-expect-error: The router we pass doesn't match the "real" router, which is fine for tests */ - children} /> + {children} );