Skip to content

Commit 400734e

Browse files
committed
Add unit tests
1 parent bfb18e6 commit 400734e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

modules/__tests__/matchRoutes-test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,35 @@ describe('matchRoutes', function () {
332332
})
333333
})
334334

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+
355+
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' })
359+
done()
360+
})
361+
})
362+
})
363+
335364
it('complains about invalid index route with path', function (done) {
336365
shouldWarn('path')
337366

0 commit comments

Comments
 (0)