diff --git a/app/soapbox/reducers/__tests__/suggestions-test.js b/app/soapbox/reducers/__tests__/suggestions-test.js index 60a7b22a1..6740bd7ba 100644 --- a/app/soapbox/reducers/__tests__/suggestions-test.js +++ b/app/soapbox/reducers/__tests__/suggestions-test.js @@ -1,5 +1,6 @@ import reducer from '../suggestions'; -import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable'; +import { SUGGESTIONS_DISMISS } from 'soapbox/actions/suggestions'; describe('suggestions reducer', () => { it('should return the initial state', () => { @@ -8,4 +9,29 @@ describe('suggestions reducer', () => { isLoading: false, })); }); + + describe('SUGGESTIONS_DISMISS', () => { + it('should remove the account', () => { + const action = { type: SUGGESTIONS_DISMISS, id: '123' }; + + const state = fromJS({ + items: [ + { account: '123', source: 'past_interactions' }, + { account: '456', source: 'past_interactions' }, + { account: '789', source: 'past_interactions' }, + ], + isLoading: false, + }); + + const expected = fromJS({ + items: [ + { account: '456', source: 'past_interactions' }, + { account: '789', source: 'past_interactions' }, + ], + isLoading: false, + }); + + expect(reducer(state, action)).toEqual(expected); + }); + }); }); diff --git a/app/soapbox/reducers/suggestions.js b/app/soapbox/reducers/suggestions.js index 6cb1b545c..509d84cf9 100644 --- a/app/soapbox/reducers/suggestions.js +++ b/app/soapbox/reducers/suggestions.js @@ -39,11 +39,11 @@ const importSuggestions = (state, suggestions) => { }; const dismissAccount = (state, accountId) => { - return state.update('items', list => list.filterNot(x => x.account === accountId)); + return state.update('items', items => items.filterNot(item => item.get('account') === accountId)); }; const dismissAccounts = (state, accountIds) => { - return state.update('items', list => list.filterNot(x => accountIds.includes(x.account))); + return state.update('items', items => items.filterNot(item => accountIds.includes(item.get('account')))); }; export default function suggestionsReducer(state = initialState, action) {