MCPcopy
hub / github.com/TanStack/router / setup

Function setup

packages/react-router/tests/useMatch.test.tsx:21–56  ·  view source on GitHub ↗
({
    RootComponent,
    history,
  }: {
    RootComponent: RouteComponent
    history?: RouterHistory
  })

Source from the content-addressed store, hash-verified

19
20describe('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])(

Callers 1

useMatch.test.tsxFile · 0.70

Calls 5

createRootRouteFunction · 0.90
createRouteFunction · 0.90
createMemoryHistoryFunction · 0.90
createRouterFunction · 0.90
renderFunction · 0.90

Tested by

no test coverage detected