From 23039c353e55f33775c322feaa915565f18c3ca9 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 9 Jun 2020 17:28:32 -0500 Subject: [PATCH] Tests: DRY mockStore() --- app/soapbox/actions/__tests__/about-test.js | 6 +----- app/soapbox/test_setup.js | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/soapbox/actions/__tests__/about-test.js b/app/soapbox/actions/__tests__/about-test.js index 941e402eb..28e7e726f 100644 --- a/app/soapbox/actions/__tests__/about-test.js +++ b/app/soapbox/actions/__tests__/about-test.js @@ -1,5 +1,3 @@ -import configureMockStore from 'redux-mock-store'; -import thunk from 'redux-thunk'; import { FETCH_ABOUT_PAGE_REQUEST, FETCH_ABOUT_PAGE_SUCCESS, @@ -8,9 +6,7 @@ import { } from '../about'; import { Map as ImmutableMap } from 'immutable'; import { __stub as stubApi } from 'soapbox/api'; - -const middlewares = [thunk]; -const mockStore = configureMockStore(middlewares); +import { mockStore } from 'soapbox/test_setup'; describe('fetchAboutPage()', () => { it('creates the expected actions on success', () => { diff --git a/app/soapbox/test_setup.js b/app/soapbox/test_setup.js index 8fa14ad2f..b185523f0 100644 --- a/app/soapbox/test_setup.js +++ b/app/soapbox/test_setup.js @@ -2,6 +2,8 @@ import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; +import thunk from 'redux-thunk'; +import configureMockStore from 'redux-mock-store'; import { __clear as clearApiMocks } from 'soapbox/api'; const adapter = new Adapter(); @@ -9,3 +11,6 @@ configure({ adapter }); jest.mock('soapbox/api'); afterEach(() => clearApiMocks()); + +const middlewares = [thunk]; +export const mockStore = configureMockStore(middlewares);