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

Function createTestRouter

packages/react-router/tests/navigate.test.tsx:16–111  ·  view source on GitHub ↗
(initialHistory?: RouterHistory)

Source from the content-addressed store, hash-verified

14})
15
16function createTestRouter(initialHistory?: RouterHistory) {
17 const history =
18 initialHistory ?? createMemoryHistory({ initialEntries: ['/'] })
19
20 const rootRoute = createRootRoute({})
21 const indexRoute = createRoute({ getParentRoute: () => rootRoute, path: '/' })
22 const postsRoute = createRoute({
23 getParentRoute: () => rootRoute,
24 path: '/posts',
25 })
26 const postIdRoute = createRoute({
27 getParentRoute: () => postsRoute,
28 path: '/$slug',
29 })
30 const projectRoute = createRoute({
31 getParentRoute: () => rootRoute,
32 path: '/p',
33 })
34 const projectIdRoute = createRoute({
35 getParentRoute: () => projectRoute,
36 path: '/$projectId',
37 })
38 const projectVersionRoute = createRoute({
39 getParentRoute: () => projectIdRoute,
40 path: '/$version',
41 })
42 const projectFrameRoute = createRoute({
43 getParentRoute: () => projectVersionRoute,
44 path: '/$framework',
45 })
46
47 const uRoute = createRoute({
48 getParentRoute: () => rootRoute,
49 path: '/u',
50 })
51 const uLayoutRoute = createRoute({
52 id: '_layout',
53 getParentRoute: () => uRoute,
54 })
55 const uUsernameRoute = createRoute({
56 getParentRoute: () => uLayoutRoute,
57 path: '$username',
58 })
59
60 const gRoute = createRoute({
61 getParentRoute: () => rootRoute,
62 path: '/g',
63 })
64 const gLayoutRoute = createRoute({
65 id: 'layout',
66 getParentRoute: () => gRoute,
67 })
68 const gUsernameRoute = createRoute({
69 getParentRoute: () => gLayoutRoute,
70 path: '$username',
71 })
72 const searchRoute = createRoute({
73 getParentRoute: () => rootRoute,

Callers 1

navigate.test.tsxFile · 0.70

Calls 4

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

Tested by

no test coverage detected