Skip to content

Commit

Permalink
test login reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiolcastro committed May 30, 2020
1 parent 122541d commit 0381a0c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/__tests__/store/login/index.spec.js
Original file line number Diff line number Diff line change
@@ -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 });
});
});

0 comments on commit 0381a0c

Please sign in to comment.