diff --git a/app/soapbox/__mocks__/api.js b/app/soapbox/__mocks__/api.js
index 9f841d2bd..b59b546ab 100644
--- a/app/soapbox/__mocks__/api.js
+++ b/app/soapbox/__mocks__/api.js
@@ -1,10 +1,17 @@
import MockAdapter from 'axios-mock-adapter';
const api = jest.requireActual('../api').default;
+let mocks = [];
+
+export const __stub = func => mocks.push(func);
+
+const setupMock = axios => {
+ const mock = new MockAdapter(axios);
+ mocks.map(func => func(mock));
+};
export default (...params) => {
- const axiosInstance = api(...params);
- const mock = new MockAdapter(axiosInstance);
- mock.onGet('/instance/about/index.html').reply(200, '
Hello world
');
- return axiosInstance;
+ const axios = api(...params);
+ setupMock(axios);
+ return axios;
};
diff --git a/app/soapbox/actions/__tests__/about-test.js b/app/soapbox/actions/__tests__/about-test.js
index df0a84572..a07dc2fda 100644
--- a/app/soapbox/actions/__tests__/about-test.js
+++ b/app/soapbox/actions/__tests__/about-test.js
@@ -6,12 +6,17 @@ import {
fetchAboutPage,
} from '../about';
import { Map as ImmutableMap } from 'immutable';
+import { __stub as stubApi } from 'soapbox/api';
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
-describe('About actions', () => {
- it('creates FETCH_ABOUT_PAGE_SUCCESS when fetching about page has been done', () => {
+describe('fetchAboutPage()', () => {
+ beforeAll(() => stubApi(mock => {
+ mock.onGet('/instance/about/index.html').reply(200, 'Hello world
');
+ }));
+
+ it('creates the expected actions', () => {
const expectedActions = [
{ type: FETCH_ABOUT_PAGE_REQUEST, slug: 'index' },
{ type: FETCH_ABOUT_PAGE_SUCCESS, slug: 'index' },