diff --git a/src/__tests__/store/login/index.spec.js b/src/__tests__/store/login/index.spec.js new file mode 100644 index 0000000..dff6345 --- /dev/null +++ b/src/__tests__/store/login/index.spec.js @@ -0,0 +1,25 @@ +import loginReducer, { Types } from '../../../store/login'; + +describe('Login Reducers', () => { + it('handle action type LOGIN_USER', () => { + const action = { + type: Types.LOGIN_USER, + payload: { name: 'NGO Pandas', id: 123 }, + }; + + const newReducer = loginReducer({ isAuthenticated: false, id: null, ongName: null }, action); + + expect(newReducer).toEqual({ isAuthenticated: true, id: 123, ongName: 'NGO Pandas' }); + }); + + it('handle action type LOGOUT_USER', () => { + const action = { + type: Types.LOGOUT_USER, + payload: {}, + }; + + const newReducer = loginReducer({ isAuthenticated: true, id: 123, ongName: 'NGO Pandas' }, action); + + expect(newReducer).toEqual({ isAuthenticated: false, id: null, ongName: null }); + }); +});