(initialHistory?: RouterHistory)
| 16 | }) |
| 17 | |
| 18 | function createTestRouter(initialHistory?: RouterHistory) { |
| 19 | const history = |
| 20 | initialHistory ?? createMemoryHistory({ initialEntries: ['/'] }) |
| 21 | |
| 22 | const rootRoute = createRootRoute({}) |
| 23 | |
| 24 | const indexRoute = createRoute({ |
| 25 | getParentRoute: () => rootRoute, |
| 26 | path: '/', |
| 27 | component: () => ( |
| 28 | <div> |
| 29 | <p>Index Route</p> |
| 30 | <ClientOnly fallback={<div data-testid="loading">Loading...</div>}> |
| 31 | <div data-testid="client-only-content">Client Only Content</div> |
| 32 | </ClientOnly> |
| 33 | </div> |
| 34 | ), |
| 35 | }) |
| 36 | |
| 37 | const routeTree = rootRoute.addChildren([indexRoute]) |
| 38 | const router = createRouter({ routeTree, history }) |
| 39 | |
| 40 | return { |
| 41 | router, |
| 42 | routes: { indexRoute }, |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | describe('ClientOnly', () => { |
| 47 | beforeEach(() => { |
no test coverage detected