From 3481b4c7280231731b6c7169c8177bd314ac7ac2 Mon Sep 17 00:00:00 2001 From: crockwave Date: Tue, 7 Jul 2020 19:38:16 -0500 Subject: [PATCH] edited height_cache-test, identity_proofs-test, and list_adder-test --- .../reducers/__tests__/height_cache-test.js | 9 ++ .../__tests__/identity_proofs-test.js | 22 +++++ .../reducers/__tests__/list_adder-test.js | 98 +++++++++++++++++++ 3 files changed, 129 insertions(+) diff --git a/app/soapbox/reducers/__tests__/height_cache-test.js b/app/soapbox/reducers/__tests__/height_cache-test.js index 4873509e5..9119a2312 100644 --- a/app/soapbox/reducers/__tests__/height_cache-test.js +++ b/app/soapbox/reducers/__tests__/height_cache-test.js @@ -1,8 +1,17 @@ import reducer from '../height_cache'; import { Map as ImmutableMap } from 'immutable'; +import { HEIGHT_CACHE_CLEAR } from '../height_cache'; describe('height_cache reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {})).toEqual(ImmutableMap()); }); + + it('should handle HEIGHT_CACHE_CLEAR', () => { + const state = ImmutableMap({ is_uploading: true }); + const action = { + type: HEIGHT_CACHE_CLEAR, + }; + expect(reducer(undefined, {})).toEqual(ImmutableMap()); + }) }); diff --git a/app/soapbox/reducers/__tests__/identity_proofs-test.js b/app/soapbox/reducers/__tests__/identity_proofs-test.js index d4d159847..1dff3d928 100644 --- a/app/soapbox/reducers/__tests__/identity_proofs-test.js +++ b/app/soapbox/reducers/__tests__/identity_proofs-test.js @@ -1,8 +1,30 @@ import reducer from '../identity_proofs'; import { Map as ImmutableMap } from 'immutable'; +import * as actions from '../identity_proofs'; describe('identity_proofs reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {})).toEqual(ImmutableMap()); }); + + // it('should handle IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST', () => { + // const state = ImmutableMap({ isLoading: false }); + // const action = { + // type: actions.IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST, + // }; + // expect(reducer(state, action).toJS()).toMatchObject({ + // isLoading: true, + // }); + // }); + // + // it('should handle IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL', () => { + // const state = ImmutableMap({ isLoading: true }); + // const action = { + // type: actions.IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL, + // }; + // expect(reducer(state, action).toJS()).toMatchObject({ + // isLoading: false, + // }); + // }); + }); diff --git a/app/soapbox/reducers/__tests__/list_adder-test.js b/app/soapbox/reducers/__tests__/list_adder-test.js index 4fcd1c3d2..b88423957 100644 --- a/app/soapbox/reducers/__tests__/list_adder-test.js +++ b/app/soapbox/reducers/__tests__/list_adder-test.js @@ -1,5 +1,6 @@ import reducer from '../list_adder'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import * as actions from '../list_adder'; describe('list_adder reducer', () => { it('should return the initial state', () => { @@ -13,4 +14,101 @@ describe('list_adder reducer', () => { }), })); }); + + it('should handle LIST_ADDER_RESET', () => { + const state = ImmutableMap({ + accountId: null, + + lists: ImmutableMap({ + items: ImmutableList(), + loaded: false, + isLoading: false, + }), + }); + const action = { + type: actions.LIST_ADDER_RESET, + }; + expect(reducer(state, action)).toEqual(ImmutableMap({ + accountId: null, + + lists: ImmutableMap({ + items: ImmutableList(), + loaded: false, + isLoading: false, + }), + })); + }); + + // it('should handle LIST_ADDER_LISTS_FETCH_REQUEST', () => { + // const state = ImmutableMap({ + // accountId: null, + // + // lists: ImmutableMap({ + // items: ImmutableList(), + // loaded: false, + // isLoading: false, + // }), + // }); + // const action = { + // type: actions.LIST_ADDER_LISTS_FETCH_REQUEST, + // }; + // expect(reducer(state, action)).toEqual(ImmutableMap({ + // accountId: null, + // + // lists: ImmutableMap({ + // items: ImmutableList(), + // loaded: false, + // isLoading: true, + // }), + // })); + // }); + + it('should handle LIST_ADDER_LISTS_FETCH_FAIL', () => { + const state = ImmutableMap({ + accountId: null, + + lists: ImmutableMap({ + items: ImmutableList(), + loaded: false, + isLoading: false, + }), + }); + const action = { + type: actions.LIST_ADDER_LISTS_FETCH_FAIL, + }; + expect(reducer(state, action)).toEqual(ImmutableMap({ + accountId: null, + + lists: ImmutableMap({ + items: ImmutableList(), + loaded: false, + isLoading: false, + }), + })); + }); + + // it('should handle LIST_ADDER_LISTS_FETCH_SUCCESS', () => { + // const state = ImmutableMap({ + // accountId: null, + // + // lists: ImmutableMap({ + // items: ImmutableList(), + // loaded: false, + // isLoading: false, + // }), + // }); + // const action = { + // type: actions.LIST_ADDER_LISTS_FETCH_SUCCESS, + // }; + // expect(reducer(state, action)).toEqual(ImmutableMap({ + // accountId: null, + // + // lists: ImmutableMap({ + // items: ImmutableList(), + // loaded: true, + // isLoading: false, + // }), + // })); + // }); + });