Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit d07150d

Browse files
committed
frontend: use RouterContextProvider instead of RouterProvider in tests
1 parent 156936f commit d07150d

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

frontend/src/test-utils/dummy-router.tsx

Whitespace-only changes.

frontend/src/test-utils/router.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
import {
16-
RouterProvider,
16+
RouterContextProvider,
1717
createMemoryHistory,
1818
createRootRoute,
1919
createRoute,
@@ -22,25 +22,15 @@ import {
2222

2323
const rootRoute = createRootRoute();
2424
const index = createRoute({ getParentRoute: () => rootRoute, path: "/" });
25-
rootRoute.addChildren([index]);
2625

2726
const router = createRouter({
2827
history: createMemoryHistory(),
29-
routeTree: rootRoute,
28+
routeTree: rootRoute.addChildren([index]),
3029
});
3130

32-
const routerReady = router.load();
33-
// Because we also use this in the stories, we need to make sure we call this only in tests
34-
if (import.meta.vitest) {
35-
// Make sure the router is ready before running any tests
36-
import("vitest").then(({ beforeAll }) =>
37-
beforeAll(async () => await routerReady),
38-
);
39-
}
40-
4131
export const DummyRouter: React.FC<React.PropsWithChildren> = ({
4232
children,
4333
}) => (
4434
/** @ts-expect-error: The router we pass doesn't match the "real" router, which is fine for tests */
45-
<RouterProvider router={router} defaultComponent={() => children} />
35+
<RouterContextProvider router={router}>{children}</RouterContextProvider>
4636
);

0 commit comments

Comments
 (0)