Created
September 8, 2017 18:26
-
-
Save abachuk/3dffc72d05f30ec71a977f317dce8b8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import configureMockStore from 'redux-mock-store'; | |
import thunk from 'redux-thunk'; | |
import moxios from 'moxios'; | |
import expect from 'expect'; | |
import * as actions from './getPosts'; | |
import getPostsMock from '../../mocks/getPostsMock'; | |
const middlewares = [thunk]; | |
const mockStore = configureMockStore(middlewares); | |
describe('getPosts actions', () => { | |
beforeEach(function () { | |
moxios.install(); | |
}); | |
afterEach(function () { | |
moxios.uninstall(); | |
}); | |
it('creates GET_POSTS_SUCCESS after successfuly fetching postse', () => { | |
moxios.wait(() => { | |
const request = moxios.requests.mostRecent(); | |
request.respondWith({ | |
status: 200, | |
response: getPostsMock, | |
}); | |
}); | |
const expectedActions = [ | |
{ type: actions.GET_POSTS_START }, | |
{ type: actions.GET_POSTS_SUCCESS, posts: getPostsMock }, | |
]; | |
const store = mockStore({ posts: {} }) | |
return store.dispatch(actions.getPosts()).then(() => { | |
// return of async actions | |
expect(store.getActions()).toEqual(expectedActions); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @abachuk What is getPostsMock? And why have you used it and you have just imported. And exactly what can share using this file