Skip to content

Instantly share code, notes, and snippets.

@shmidtelson
Last active November 15, 2019 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shmidtelson/a2042a92ca5f3d701ebbb7b6eabf3980 to your computer and use it in GitHub Desktop.
Save shmidtelson/a2042a92ca5f3d701ebbb7b6eabf3980 to your computer and use it in GitHub Desktop.
qweqwe
import reducer, { initialState } from './reducer'
import * as t from './actionTypes'
describe('session reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(initialState)
})
it('LOG_IN_REQUEST', () => {
const action = { // РАБ СИСТЕМЫ // САМ РАБ
type: t.LOG_IN_REQUEST,
}
expect(reducer(initialState, action)).toEqual({
...initialState,
isLoading: true,
errorMsg: null,
})
})
it('LOG_IN_SUCCESS', () => {
const action = {
type: t.LOG_IN_SUCCESS,
payload: {
email: 'm@m.com',
},
errorMsg: null,
}
expect(reducer(initialState, action)).toEqual({
...initialState,
isLoading: false,
user: {
name: 'm@m.com',
},
errorMsg: null,
})
})
it('LOG_IN_FAILURE', () => {
const action = {
type: t.LOG_IN_FAILURE,
payload: {
errorMsg: 'something going wrong',
},
error: true,
}
expect(reducer(initialState, action)).toEqual({
...initialState,
isLoading: false,
errorMsg: 'something going wrong',
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment