parent
85a56d86f3
commit
6810f8d0b6
@ -0,0 +1,10 @@
|
||||
import MockAdapter from 'axios-mock-adapter';
|
||||
|
||||
const api = jest.requireActual('../api').default;
|
||||
|
||||
export default (...params) => {
|
||||
const axiosInstance = api(...params);
|
||||
const mock = new MockAdapter(axiosInstance);
|
||||
mock.onGet('/instance/about/index.html').reply(200, '<h1>Hello world</h1>');
|
||||
return axiosInstance;
|
||||
};
|
@ -0,0 +1,25 @@
|
||||
import configureMockStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
import {
|
||||
FETCH_ABOUT_PAGE_REQUEST,
|
||||
FETCH_ABOUT_PAGE_SUCCESS,
|
||||
fetchAboutPage,
|
||||
} from '../about';
|
||||
import { Map as ImmutableMap } from 'immutable';
|
||||
|
||||
const middlewares = [thunk];
|
||||
const mockStore = configureMockStore(middlewares);
|
||||
|
||||
describe('About actions', () => {
|
||||
it('creates FETCH_ABOUT_PAGE_SUCCESS when fetching about page has been done', () => {
|
||||
const expectedActions = [
|
||||
{ type: FETCH_ABOUT_PAGE_REQUEST, slug: 'index' },
|
||||
{ type: FETCH_ABOUT_PAGE_SUCCESS, slug: 'index' },
|
||||
];
|
||||
const store = mockStore(ImmutableMap());
|
||||
|
||||
return store.dispatch(fetchAboutPage()).then(() => {
|
||||
expect(store.getActions()).toEqual(expectedActions);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in new issue