(opts: { isServer: boolean })
| 17 | }) |
| 18 | |
| 19 | function createTestRouter(opts: { isServer: boolean }) { |
| 20 | const history = 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 | const otherRoute = createRoute({ |
| 37 | getParentRoute: () => rootRoute, |
| 38 | path: '/other', |
| 39 | component: () => ( |
| 40 | <div> |
| 41 | <p data-testid="other-route">Other Route</p> |
| 42 | </div> |
| 43 | ), |
| 44 | }) |
| 45 | |
| 46 | const routeTree = rootRoute.addChildren([indexRoute, otherRoute]) |
| 47 | const router = createRouter({ routeTree, history, ...opts }) |
| 48 | |
| 49 | return { |
| 50 | router, |
| 51 | routes: { indexRoute }, |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | describe('ClientOnly', () => { |
| 56 | it('should render fallback during SSR', async () => { |
no test coverage detected