Guest User

Untitled

a guest
Dec 15th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import Session from '../session-index'
  2. import { mockUser } from '../__mocks__/data'
  3.  
  4. describe('[SessionReducer]', () => {
  5.  
  6. it('shd return the initial state', () => {
  7.  
  8. const { Reducer } = Session
  9.  
  10. //First, we get the initial state of the reducer
  11. const initialState = Reducer()
  12.  
  13. //Then, we validate the initial state
  14. expect(initialState).toEqual({ user: null })
  15. })
  16.  
  17. it('shd return the loggedInState when setUser action is dispatched', () => {
  18.  
  19. const { Actions: { setUser }, Reducer } = Session
  20.  
  21. //We call the setUser user action
  22. //by parsing it as a param to our Reducer
  23. const loggedInState = Reducer(undefined, setUser(mockUser))
  24.  
  25. //Then, we validate the logged in state
  26. expect(loggedInState).toEqual({ user: mockUser })
  27. })
  28. })
Add Comment
Please, Sign In to add comment