File tree 1 file changed +21
-0
lines changed
packages/react-router/tests
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,27 @@ describe('onEnter event', () => {
192
192
193
193
expect ( fn ) . toHaveBeenCalledWith ( { foo : 'bar' } )
194
194
} )
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
+ } )
195
216
} )
196
217
197
218
describe ( 'route.head' , ( ) => {
You can’t perform that action at this time.
0 commit comments