Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
Adds navigate object to route payload passed to actions and events,…
Browse files Browse the repository at this point in the history
… per documentation in docs/api/navigateAction.md. Adds test.
  • Loading branch information
pumpikano committed Jul 11, 2015
1 parent 4b6f086 commit e62aea1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/RouteStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var RouteStore = createStore({
r.set('url', route.url);
r.set('params', Immutable.fromJS(route.params));
r.set('query', Immutable.fromJS(self._parseQueryString(matchedUrl)));
r.set('navigate', Immutable.fromJS(route.navigate));
});

return route;
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/lib/navigateAction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ describe('navigateAction', function () {
});
});

it('should include navigate object on route match', function (done) {
var url = '/';
navigateAction(mockContext, {
url: url,
someKey1: 'someData',
someKey2: {
someKey3: ['a', 'b']
}
}, function (err) {
expect(err).to.equal(undefined);
expect(mockContext.dispatchCalls.length).to.equal(2);
expect(mockContext.dispatchCalls[0].name).to.equal('NAVIGATE_START');
var route = mockContext.getStore('RouteStore').getCurrentRoute();
expect(route.toJS().navigate).to.eql({url: url, someKey1: 'someData', someKey2: {someKey3: ['a', 'b']}}, 'navigate added to route payload for NAVIGATE_START' + JSON.stringify(route));
done();
});
});

it('should not call execute action if there is no action', function (done) {
navigateAction(mockContext, {
url: '/'
Expand Down

0 comments on commit e62aea1

Please sign in to comment.