Skip to content

Commit

Permalink
Merge pull request #36 from skimi/master
Browse files Browse the repository at this point in the history
Pass the event of ui-router in the payloads
  • Loading branch information
neilff committed Feb 5, 2016
2 parents 62b0f67 + c762b11 commit b7aef48
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/__tests__/router-state-reducer.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'chai';
import chai from 'chai';
import routerStateReducer from '../router-state-reducer';

describe('routerStateReducer', () => {
Expand All @@ -19,6 +19,7 @@ describe('routerStateReducer', () => {
let action = {
type: '@@reduxUiRouter/$stateChangeSuccess',
payload: {
evt: 'evt',
currentState: 'currentState',
currentParams: 'currentParams',
prevState: 'prevState',
Expand All @@ -27,6 +28,7 @@ describe('routerStateReducer', () => {
};

let state = routerStateReducer(undefined, action);
chai.should().not.exist(state.evt);
expect(state.currentState).to.equal('currentState');
expect(state.currentParams).to.equal('currentParams');
expect(state.prevState).to.equal('prevState');
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/state-change-error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('stateChangeError', () => {
expect(action.payload.fromState).to.equal('fromState');
expect(action.payload.fromParams).to.equal('fromParams');
expect(action.payload.err).to.equal('err');
expect(action.payload.evt).to.equal('evt');
expect(action.type).to.equal('@@reduxUiRouter/$stateChangeError');
});
});
1 change: 1 addition & 0 deletions src/__tests__/state-change-start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('stateChangeStart', () => {
expect(action.payload.toParams).to.equal('toParams');
expect(action.payload.fromState).to.equal('fromState');
expect(action.payload.fromParams).to.equal('fromParams');
expect(action.payload.evt).to.equal('evt');
expect(action.type).to.equal('@@reduxUiRouter/$stateChangeStart');
});
});
8 changes: 5 additions & 3 deletions src/router-state-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const INITIAL_STATE = {
* @return {Object} New state
*/
export default function routerStateReducer(state = INITIAL_STATE, action) {
return action.type === STATE_CHANGE_SUCCESS
? action.payload
: state;
if (action.type !== STATE_CHANGE_SUCCESS) {
return state;
}
delete action.payload.evt;
return action.payload;
}
1 change: 1 addition & 0 deletions src/state-change-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function onStateChangeError(evt, toState, toParams, fromState, fr
return {
type: STATE_CHANGE_ERROR,
payload: {
evt,
toState,
toParams,
fromState,
Expand Down
1 change: 1 addition & 0 deletions src/state-change-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function onStateChangeStart(evt, toState, toParams, fromState, fr
return {
type: STATE_CHANGE_START,
payload: {
evt,
toState,
toParams,
fromState,
Expand Down

0 comments on commit b7aef48

Please sign in to comment.