@@ -291,11 +291,10 @@ describe('matchRoutes', function () {
291
291
} )
292
292
293
293
describe ( 'an asynchronous JSX route config' , function ( ) {
294
- let getChildRoutes , getIndexRoute , jsxRoutes , jsxNestedRoutes , state
294
+ let getChildRoutes , getIndexRoute , jsxRoutes , makeJsxNestedRoutes
295
295
296
296
beforeEach ( function ( ) {
297
297
getChildRoutes = function ( partialNextState , callback ) {
298
- state = partialNextState
299
298
setTimeout ( function ( ) {
300
299
callback ( null , < Route path = ":userID" /> )
301
300
} )
@@ -313,15 +312,19 @@ describe('matchRoutes', function () {
313
312
getChildRoutes = { getChildRoutes }
314
313
getIndexRoute = { getIndexRoute } />
315
314
] )
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
- ] )
315
+
316
+ makeJsxNestedRoutes = ( ) => {
317
+ const spy = expect . spyOn ( { getChildRoutes } , 'getChildRoutes' ) . andCallThrough ( )
318
+ const routes = createRoutes ( [
319
+ < Route name = "users"
320
+ path = "users/:id" >
321
+ < Route name = "topic"
322
+ path = ":topic"
323
+ getChildRoutes = { spy } />
324
+ </ Route >
325
+ ] )
326
+ return { spy, routes }
327
+ }
325
328
} )
326
329
327
330
it ( 'when getChildRoutes callback returns reactElements' , function ( done ) {
@@ -342,7 +345,9 @@ describe('matchRoutes', function () {
342
345
} )
343
346
344
347
it ( 'when getChildRoutes callback returns partialNextState' , function ( done ) {
345
- matchRoutes ( jsxNestedRoutes , createLocation ( '/users/5/details/others' ) , function ( ) {
348
+ const jsxNestedRoutes = makeJsxNestedRoutes ( )
349
+ matchRoutes ( jsxNestedRoutes . routes , createLocation ( '/users/5/details/others' ) , function ( ) {
350
+ const state = jsxNestedRoutes . spy . calls [ 0 ] . arguments [ 0 ]
346
351
expect ( state ) . toExist ( )
347
352
expect ( state . params ) . toEqual ( { id : '5' , topic : 'details' } )
348
353
done ( )
0 commit comments