Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make params available to getChildRoutes providers #3556

Merged
29 changes: 29 additions & 0 deletions modules/__tests__/matchRoutes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,35 @@ describe('matchRoutes', function () {
})
})

describe('a nested route with a getChildRoutes callback', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you combine this with the previous describe() block? They're really covering the same thing.

let getChildRoutes, jsxRoutes

beforeEach(function () {
getChildRoutes = function (partialNextState, callback) {
setTimeout(function () {
callback(null, partialNextState)
})
}

jsxRoutes = createRoutes([
<Route name="users"
path="users/:id">
<Route name="topic"
path=":topic"
getChildRoutes={getChildRoutes} />
</Route>
])
})

it('when getChildRoutes callback returns partialNextState', function (done) {
matchRoutes(jsxRoutes, createLocation('/users/5/details'), function (error, partialNextState) {
expect(partialNextState).toExist()
expect(partialNextState.params).toEqual({ id: '5', topic: 'details' })
done()
})
})
})

it('complains about invalid index route with path', function (done) {
shouldWarn('path')

Expand Down