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

Commit

Permalink
Fix account removed reducer to check also network
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Nov 8, 2017
1 parent 405996d commit b03e510
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/store/reducers/savedAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const savedAccounts = (state = [], action) => {
action.data,
];
case actionTypes.accountRemoved:
return state.filter(account => account.publicKey !== action.data);
return state.filter(account =>
!(account.publicKey === action.data.publicKey &&
account.network === action.data.network));
default:
return state;
}
Expand Down
3 changes: 1 addition & 2 deletions src/store/reducers/savedAccounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ describe('Reducer: savedAccounts(state, action)', () => {
});

it('should return array without given account if action.type = actionTypes.accountRemoved', () => {
const publicKey = 'sample_key_1';
const state = [account];
const action = {
type: actionTypes.accountRemoved,
data: publicKey,
data: account,
};
const changedState = savedAccounts(state, action);
expect(changedState).to.deep.equal([]);
Expand Down

0 comments on commit b03e510

Please sign in to comment.