diff --git a/app/soapbox/__fixtures__/accounts_counter_follow.json b/app/soapbox/__fixtures__/accounts_counter_follow.json new file mode 100644 index 000000000..3d2faf801 --- /dev/null +++ b/app/soapbox/__fixtures__/accounts_counter_follow.json @@ -0,0 +1,7 @@ +{ + "9vMAje101ngtjlMj7w": { + "followers_count": 3, + "following_count": 2, + "statuses_count": 2 + } +} diff --git a/app/soapbox/__fixtures__/accounts_counter_initial.json b/app/soapbox/__fixtures__/accounts_counter_initial.json new file mode 100644 index 000000000..ce9b3279e --- /dev/null +++ b/app/soapbox/__fixtures__/accounts_counter_initial.json @@ -0,0 +1,7 @@ +{ + "9vMAje101ngtjlMj7w": { + "followers_count": 2, + "following_count": 2, + "statuses_count": 2 + } +} diff --git a/app/soapbox/__fixtures__/accounts_counter_unfollow.json b/app/soapbox/__fixtures__/accounts_counter_unfollow.json new file mode 100644 index 000000000..285e4c6f2 --- /dev/null +++ b/app/soapbox/__fixtures__/accounts_counter_unfollow.json @@ -0,0 +1,7 @@ +{ + "9vMAje101ngtjlMj7w": { + "followers_count": 1, + "following_count": 2, + "statuses_count": 2 + } +} diff --git a/app/soapbox/reducers/__tests__/accounts_counters-test.js b/app/soapbox/reducers/__tests__/accounts_counters-test.js index f6c9e3bb0..c39c95938 100644 --- a/app/soapbox/reducers/__tests__/accounts_counters-test.js +++ b/app/soapbox/reducers/__tests__/accounts_counters-test.js @@ -1,8 +1,35 @@ import reducer from '../accounts_counters'; import { Map as ImmutableMap } from 'immutable'; +import { ACCOUNT_FOLLOW_SUCCESS, ACCOUNT_UNFOLLOW_SUCCESS } from 'soapbox/actions/accounts'; +import relationship from 'soapbox/__fixtures__/relationship.json'; +import accounts_counter_initial from 'soapbox/__fixtures__/accounts_counter_initial.json'; +import accounts_counter_unfollow from 'soapbox/__fixtures__/accounts_counter_unfollow.json'; +import accounts_counter_follow from 'soapbox/__fixtures__/accounts_counter_follow.json'; + describe('accounts_counters reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {})).toEqual(ImmutableMap()); }); + + it('should handle ACCOUNT_FOLLOW_SUCCESS', () => { + // const state = accounts_counter_initial; + const action = { + type: ACCOUNT_FOLLOW_SUCCESS, + relationship: relationship, + alreadyFollowing: false, + }; + expect(reducer(accounts_counter_initial, action)).toEqual( accounts_counter_follow ); + }); + + it('should handle ACCOUNT_UNFOLLOW_SUCCESS', () => { + // const state = accounts_counter_initial; + const action = { + type: ACCOUNT_UNFOLLOW_SUCCESS, + relationship: relationship, + alreadyFollowing: true, + }; + expect(reducer(accounts_counter_initial, action)).toEqual( accounts_counter_unfollow ); + }); + });