11import { describe , expect , it , test } from 'vitest' ;
2- import { checkRouteForAsyncHandler } from '../src/lazy-route-utils' ;
3- import { getNumberOfUrlSegments } from '../src/reactrouterv6-compat-utils' ;
2+ import {
3+ checkRouteForAsyncHandler ,
4+ getNumberOfUrlSegments ,
5+ processResolvedRoutes ,
6+ } from '../src/reactrouter-compat-utils' ;
47import type { RouteObject } from '../src/types' ;
58
6- // Mock processResolvedRoutes function for tests
7- const mockProcessResolvedRoutes = ( ) => { } ;
8-
99describe ( 'getNumberOfUrlSegments' , ( ) => {
1010 test . each ( [
1111 [ 'regular path' , '/projects/123/views/234' , 4 ] ,
@@ -27,8 +27,8 @@ describe('checkRouteForAsyncHandler', () => {
2727 } ,
2828 } ;
2929
30- checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ;
31- checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ;
30+ checkRouteForAsyncHandler ( route , processResolvedRoutes ) ;
31+ checkRouteForAsyncHandler ( route , processResolvedRoutes ) ;
3232
3333 const proxiedHandler = route . handle ?. lazyChildren ;
3434 expect ( typeof proxiedHandler ) . toBe ( 'function' ) ;
@@ -45,7 +45,7 @@ describe('checkRouteForAsyncHandler', () => {
4545 path : '/test' ,
4646 } ;
4747
48- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
48+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
4949 } ) ;
5050
5151 it ( 'should handle routes with non-function handle properties' , ( ) => {
@@ -56,7 +56,7 @@ describe('checkRouteForAsyncHandler', () => {
5656 } ,
5757 } ;
5858
59- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
59+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
6060 } ) ;
6161
6262 it ( 'should handle routes with null/undefined handle properties' , ( ) => {
@@ -65,7 +65,7 @@ describe('checkRouteForAsyncHandler', () => {
6565 handle : null as any ,
6666 } ;
6767
68- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
68+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
6969 } ) ;
7070
7171 it ( 'should handle routes with mixed function and non-function handle properties' , ( ) => {
@@ -79,7 +79,7 @@ describe('checkRouteForAsyncHandler', () => {
7979 } ,
8080 } ;
8181
82- checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ;
82+ checkRouteForAsyncHandler ( route , processResolvedRoutes ) ;
8383
8484 const proxiedHandler = route . handle ?. lazyChildren ;
8585 expect ( typeof proxiedHandler ) . toBe ( 'function' ) ;
@@ -110,7 +110,7 @@ describe('checkRouteForAsyncHandler', () => {
110110 ] ,
111111 } ;
112112
113- checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ;
113+ checkRouteForAsyncHandler ( route , processResolvedRoutes ) ;
114114
115115 // Check parent handler is proxied
116116 const proxiedParentHandler = route . handle ?. lazyChildren ;
@@ -153,7 +153,7 @@ describe('checkRouteForAsyncHandler', () => {
153153 ] ,
154154 } ;
155155
156- checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ;
156+ checkRouteForAsyncHandler ( route , processResolvedRoutes ) ;
157157
158158 // Check all handlers are proxied
159159 expect ( ( route . handle ?. lazyChildren as { __sentry_proxied__ ?: boolean } ) . __sentry_proxied__ ) . toBe ( true ) ;
@@ -179,7 +179,7 @@ describe('checkRouteForAsyncHandler', () => {
179179 } ,
180180 } ;
181181
182- checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ;
182+ checkRouteForAsyncHandler ( route , processResolvedRoutes ) ;
183183
184184 // Check all handlers are proxied
185185 expect ( ( route . handle ?. lazyChildren as { __sentry_proxied__ ?: boolean } ) . __sentry_proxied__ ) . toBe ( true ) ;
@@ -197,13 +197,13 @@ describe('checkRouteForAsyncHandler', () => {
197197 } ;
198198
199199 // First call should proxy the function
200- checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ;
200+ checkRouteForAsyncHandler ( route , processResolvedRoutes ) ;
201201 const firstProxiedHandler = route . handle ?. lazyChildren ;
202202 expect ( firstProxiedHandler ) . not . toBe ( mockHandler ) ;
203203 expect ( ( firstProxiedHandler as { __sentry_proxied__ ?: boolean } ) . __sentry_proxied__ ) . toBe ( true ) ;
204204
205205 // Second call should not create a new proxy
206- checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ;
206+ checkRouteForAsyncHandler ( route , processResolvedRoutes ) ;
207207 const secondProxiedHandler = route . handle ?. lazyChildren ;
208208 expect ( secondProxiedHandler ) . toBe ( firstProxiedHandler ) ; // Should be the same proxy
209209 expect ( ( secondProxiedHandler as { __sentry_proxied__ ?: boolean } ) . __sentry_proxied__ ) . toBe ( true ) ;
@@ -215,7 +215,7 @@ describe('checkRouteForAsyncHandler', () => {
215215 children : [ ] ,
216216 } ;
217217
218- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
218+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
219219 } ) ;
220220
221221 it ( 'should handle routes with undefined children' , ( ) => {
@@ -224,7 +224,7 @@ describe('checkRouteForAsyncHandler', () => {
224224 children : undefined ,
225225 } ;
226226
227- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
227+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
228228 } ) ;
229229
230230 it ( 'should handle routes with null children' , ( ) => {
@@ -233,7 +233,7 @@ describe('checkRouteForAsyncHandler', () => {
233233 children : null as any ,
234234 } ;
235235
236- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
236+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
237237 } ) ;
238238
239239 it ( 'should handle routes with non-array children' , ( ) => {
@@ -242,7 +242,7 @@ describe('checkRouteForAsyncHandler', () => {
242242 children : 'not an array' as any ,
243243 } ;
244244
245- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
245+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
246246 } ) ;
247247
248248 it ( 'should handle routes with handle that is not an object' , ( ) => {
@@ -251,7 +251,7 @@ describe('checkRouteForAsyncHandler', () => {
251251 handle : 'not an object' as any ,
252252 } ;
253253
254- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
254+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
255255 } ) ;
256256
257257 it ( 'should handle routes with handle that is null' , ( ) => {
@@ -260,7 +260,7 @@ describe('checkRouteForAsyncHandler', () => {
260260 handle : null as any ,
261261 } ;
262262
263- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
263+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
264264 } ) ;
265265
266266 it ( 'should handle routes with handle that is undefined' , ( ) => {
@@ -269,7 +269,7 @@ describe('checkRouteForAsyncHandler', () => {
269269 handle : undefined as any ,
270270 } ;
271271
272- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
272+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
273273 } ) ;
274274
275275 it ( 'should handle routes with handle that is a function' , ( ) => {
@@ -278,7 +278,7 @@ describe('checkRouteForAsyncHandler', () => {
278278 handle : ( ( ) => { } ) as any ,
279279 } ;
280280
281- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
281+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
282282 } ) ;
283283
284284 it ( 'should handle routes with handle that is a string' , ( ) => {
@@ -287,7 +287,7 @@ describe('checkRouteForAsyncHandler', () => {
287287 handle : 'string handle' as any ,
288288 } ;
289289
290- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
290+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
291291 } ) ;
292292
293293 it ( 'should handle routes with handle that is a number' , ( ) => {
@@ -296,7 +296,7 @@ describe('checkRouteForAsyncHandler', () => {
296296 handle : 42 as any ,
297297 } ;
298298
299- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
299+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
300300 } ) ;
301301
302302 it ( 'should handle routes with handle that is a boolean' , ( ) => {
@@ -305,7 +305,7 @@ describe('checkRouteForAsyncHandler', () => {
305305 handle : true as any ,
306306 } ;
307307
308- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
308+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
309309 } ) ;
310310
311311 it ( 'should handle routes with handle that is an array' , ( ) => {
@@ -314,6 +314,6 @@ describe('checkRouteForAsyncHandler', () => {
314314 handle : [ ] as any ,
315315 } ;
316316
317- expect ( ( ) => checkRouteForAsyncHandler ( route , mockProcessResolvedRoutes ) ) . not . toThrow ( ) ;
317+ expect ( ( ) => checkRouteForAsyncHandler ( route , processResolvedRoutes ) ) . not . toThrow ( ) ;
318318 } ) ;
319319} ) ;
0 commit comments