From 8da7b8fe7a1dd349c295fdc0f30efe200376ceb1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 6 Jul 2022 15:25:07 -0500 Subject: [PATCH] Fix rootState type in tests --- app/soapbox/jest/test-helpers.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/soapbox/jest/test-helpers.tsx b/app/soapbox/jest/test-helpers.tsx index 12e0a2ebb..d31d01bfd 100644 --- a/app/soapbox/jest/test-helpers.tsx +++ b/app/soapbox/jest/test-helpers.tsx @@ -1,6 +1,6 @@ import { configureMockStore } from '@jedmao/redux-mock-store'; import { render, RenderOptions } from '@testing-library/react'; -import { merge } from 'immutable'; +import { merge, Record as ImmutableRecord } from 'immutable'; import React, { FC, ReactElement } from 'react'; import { IntlProvider } from 'react-intl'; import { Provider } from 'react-redux'; @@ -17,7 +17,8 @@ import type { AppDispatch } from 'soapbox/store'; // Mock Redux // https://redux.js.org/recipes/writing-tests/ -let rootState = rootReducer(undefined, {} as Action); +const gg = rootReducer(undefined, {} as Action); +const rootState = gg as unknown as ImmutableRecord; const mockStore = configureMockStore([thunk]); /** Apply actions to the state, one at a time. */ @@ -29,12 +30,13 @@ const createTestStore = (initialState: any) => createStore(rootReducer, initialS const TestApp: FC = ({ children, storeProps, routerProps = {} }) => { let store: any; + let appState = rootState; if (storeProps) { - rootState = merge(rootState, storeProps); - store = createTestStore(rootState); + appState = merge(rootState, storeProps); + store = createTestStore(appState); } else { - store = createTestStore(rootState); + store = createTestStore(appState); } const props = {