Skip to content

Commit 1057c98

Browse files
committed
tests
1 parent e6aef99 commit 1057c98

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: packages/react-router/tests/route.test.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,27 @@ describe('onEnter event', () => {
192192

193193
expect(fn).toHaveBeenCalledWith({ foo: 'bar' })
194194
})
195+
196+
it('should have location defined in router.load()', async () => {
197+
const fn = vi.fn()
198+
const rootRoute = createRootRoute()
199+
const indexRoute = createRoute({
200+
getParentRoute: () => rootRoute,
201+
path: '/',
202+
component: () => {
203+
return <h1>Index</h1>
204+
},
205+
onEnter: (_, { location }) => {
206+
fn(location)
207+
},
208+
})
209+
const routeTree = rootRoute.addChildren([indexRoute])
210+
const router = createRouter({ routeTree })
211+
212+
await router.load()
213+
214+
expect(fn).toHaveBeenCalledWith({ pathname: '/' })
215+
})
195216
})
196217

197218
describe('route.head', () => {

0 commit comments

Comments
 (0)