Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import configureMockStore from 'redux-mock-store'
- import thunk from 'redux-thunk'
- import * as actions from '../../actions/session'
- import * as types from '../../constants/ActionTypes'
- import nock from 'nock'
- import expect from 'expect'
- const middlewares = [thunk];
- const mockStore = configureMockStore(middlewares);
- describe('sign-in', () => {
- afterEach(() => {
- nock.cleanAll()
- });
- it('creates SIGN_IN when sign-in has been done', () => {
- const data = {email: 'test@mail.ru', password: 'testPass'};
- nock('https://localhost:7070/my')
- .post('/api/v1/users/sign_in', data)
- .reply(200, {
- jwt: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MDM1OTQ3MDksInVzZXJfaWQiOjl9.hcPqEm4xwMj78KsrB-l1La5QlgaqqMIe4MHa1CeIyiY"
- });
- const expectedActions = [
- {type: types.REQUEST_SIGN_IN,},
- {
- type: types.SUCCESS_SIGN_IN, token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MDM1OTQ3MDksInVzZXJfaWQiOjl9.hcPqEm4xwMj78KsrB-l1La5QlgaqqMIe4MHa1CeIyiY"
- }
- ];
- const store = mockStore({user: null});
- return store.dispatch(actions.signIn(data))
- .then(() => { // return of async actions
- expect(store.getActions()).toEqual(expectedActions)
- })
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement