({
RootComponent,
history,
}: {
RootComponent: RouteComponent
history?: RouterHistory
})
| 19 | |
| 20 | describe('useMatch', () => { |
| 21 | function setup({ |
| 22 | RootComponent, |
| 23 | history, |
| 24 | }: { |
| 25 | RootComponent: RouteComponent |
| 26 | history?: RouterHistory |
| 27 | }) { |
| 28 | const rootRoute = createRootRoute({ |
| 29 | component: RootComponent, |
| 30 | }) |
| 31 | const indexRoute = createRoute({ |
| 32 | getParentRoute: () => rootRoute, |
| 33 | path: '/', |
| 34 | component: () => ( |
| 35 | <> |
| 36 | <h1>IndexTitle</h1> |
| 37 | <Link to="/posts">Posts</Link> |
| 38 | </> |
| 39 | ), |
| 40 | }) |
| 41 | |
| 42 | history = history || createMemoryHistory({ initialEntries: ['/'] }) |
| 43 | |
| 44 | const postsRoute = createRoute({ |
| 45 | getParentRoute: () => rootRoute, |
| 46 | path: '/posts', |
| 47 | component: () => <h1>PostsTitle</h1>, |
| 48 | }) |
| 49 | |
| 50 | const router = createRouter({ |
| 51 | routeTree: rootRoute.addChildren([indexRoute, postsRoute]), |
| 52 | history, |
| 53 | }) |
| 54 | |
| 55 | return render(<RouterProvider router={router} />) |
| 56 | } |
| 57 | |
| 58 | describe('when match is found', () => { |
| 59 | test.each([true, false, undefined])( |
no test coverage detected