( options?: RouterOptions<AnyRoute, 'never', any, any, any>, )
| 49 | } |
| 50 | |
| 51 | function createTestRouter( |
| 52 | options?: RouterOptions<AnyRoute, 'never', any, any, any>, |
| 53 | ) { |
| 54 | const rootRoute = createRootRoute({ |
| 55 | validateSearch: z.object({ root: z.string().optional() }), |
| 56 | component: () => { |
| 57 | const search = rootRoute.useSearch() |
| 58 | return ( |
| 59 | <> |
| 60 | <div data-testid="search-root">{search().root ?? '$undefined'}</div> |
| 61 | <Outlet /> |
| 62 | </> |
| 63 | ) |
| 64 | }, |
| 65 | }) |
| 66 | const indexRoute = createRoute({ getParentRoute: () => rootRoute, path: '/' }) |
| 67 | const usersRoute = createRoute({ |
| 68 | getParentRoute: () => rootRoute, |
| 69 | path: '/users', |
| 70 | }) |
| 71 | const userRoute = createRoute({ |
| 72 | getParentRoute: () => usersRoute, |
| 73 | path: '/$userId', |
| 74 | }) |
| 75 | const userFilesRoute = createRoute({ |
| 76 | getParentRoute: () => userRoute, |
| 77 | path: '/files/$fileId', |
| 78 | }) |
| 79 | const postsRoute = createRoute({ |
| 80 | getParentRoute: () => rootRoute, |
| 81 | path: '/posts', |
| 82 | }) |
| 83 | const postIdRoute = createRoute({ |
| 84 | getParentRoute: () => postsRoute, |
| 85 | path: '/$slug', |
| 86 | }) |
| 87 | const topLevelSplatRoute = createRoute({ |
| 88 | getParentRoute: () => rootRoute, |
| 89 | path: '$', |
| 90 | }) |
| 91 | // This is simulates a user creating a `é.tsx` file using file-based routing |
| 92 | const pathSegmentEAccentRoute = createRoute({ |
| 93 | getParentRoute: () => rootRoute, |
| 94 | path: '/path-segment/é', |
| 95 | }) |
| 96 | // This is simulates a user creating a `🚀.tsx` file using file-based routing |
| 97 | const pathSegmentRocketEmojiRoute = createRoute({ |
| 98 | getParentRoute: () => rootRoute, |
| 99 | path: '/path-segment/🚀', |
| 100 | }) |
| 101 | const pathSegmentSoloSplatRoute = createRoute({ |
| 102 | getParentRoute: () => rootRoute, |
| 103 | path: '/solo-splat/$', |
| 104 | }) |
| 105 | const pathSegmentLayoutSplatRoute = createRoute({ |
| 106 | getParentRoute: () => rootRoute, |
| 107 | path: '/layout-splat', |
| 108 | }) |
no test coverage detected