@@ -291,15 +291,16 @@ describe('matchRoutes', function () {
291
291
} )
292
292
293
293
describe ( 'an asynchronous JSX route config' , function ( ) {
294
- let getChildRoutes , getIndexRoute , jsxRoutes
294
+ let getChildRoutes , getIndexRoute , jsxRoutes , jsxNestedRoutes , state
295
295
296
296
beforeEach ( function ( ) {
297
297
getChildRoutes = function ( partialNextState , callback ) {
298
+ state = partialNextState
298
299
setTimeout ( function ( ) {
299
300
callback ( null , < Route path = ":userID" /> )
300
301
} )
301
302
}
302
-
303
+
303
304
getIndexRoute = function ( location , callback ) {
304
305
setTimeout ( function ( ) {
305
306
callback ( null , < Route name = "jsx" /> )
@@ -310,9 +311,18 @@ describe('matchRoutes', function () {
310
311
< Route name = "users"
311
312
path = "users"
312
313
getChildRoutes = { getChildRoutes }
313
- getIndexRoute = { getIndexRoute } />
314
+ getIndexRoute = { getIndexRoute } />
314
315
] )
315
- } )
316
+
317
+ jsxNestedRoutes = createRoutes ( [
318
+ < Route name = "users"
319
+ path = "users/:id" >
320
+ < Route name = "topic"
321
+ path = ":topic"
322
+ getChildRoutes = { getChildRoutes } />
323
+ </ Route >
324
+ ] )
325
+ } )
316
326
317
327
it ( 'when getChildRoutes callback returns reactElements' , function ( done ) {
318
328
matchRoutes ( jsxRoutes , createLocation ( '/users/5' ) , function ( error , match ) {
@@ -330,32 +340,11 @@ describe('matchRoutes', function () {
330
340
done ( )
331
341
} )
332
342
} )
333
- } )
334
-
335
- describe ( 'a nested route with a getChildRoutes callback' , function ( ) {
336
- let getChildRoutes , jsxRoutes
337
-
338
- beforeEach ( function ( ) {
339
- getChildRoutes = function ( partialNextState , callback ) {
340
- setTimeout ( function ( ) {
341
- callback ( null , partialNextState )
342
- } )
343
- }
344
-
345
- jsxRoutes = createRoutes ( [
346
- < Route name = "users"
347
- path = "users/:id" >
348
- < Route name = "topic"
349
- path = ":topic"
350
- getChildRoutes = { getChildRoutes } />
351
- </ Route >
352
- ] )
353
- } )
354
-
343
+
355
344
it ( 'when getChildRoutes callback returns partialNextState' , function ( done ) {
356
- matchRoutes ( jsxRoutes , createLocation ( '/users/5/details' ) , function ( error , partialNextState ) {
357
- expect ( partialNextState ) . toExist ( )
358
- expect ( partialNextState . params ) . toEqual ( { id : '5' , topic : 'details' } )
345
+ matchRoutes ( jsxNestedRoutes , createLocation ( '/users/5/details/others ' ) , function ( ) {
346
+ expect ( state ) . toExist ( )
347
+ expect ( state . params ) . toEqual ( { id : '5' , topic : 'details' } )
359
348
done ( )
360
349
} )
361
350
} )
0 commit comments