Fix rootState type in tests
This commit is contained in:
parent
06d3f00170
commit
8da7b8fe7a
|
@ -1,6 +1,6 @@
|
||||||
import { configureMockStore } from '@jedmao/redux-mock-store';
|
import { configureMockStore } from '@jedmao/redux-mock-store';
|
||||||
import { render, RenderOptions } from '@testing-library/react';
|
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 React, { FC, ReactElement } from 'react';
|
||||||
import { IntlProvider } from 'react-intl';
|
import { IntlProvider } from 'react-intl';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
|
@ -17,7 +17,8 @@ import type { AppDispatch } from 'soapbox/store';
|
||||||
|
|
||||||
// Mock Redux
|
// Mock Redux
|
||||||
// https://redux.js.org/recipes/writing-tests/
|
// 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<typeof gg>;
|
||||||
const mockStore = configureMockStore<typeof rootState, AnyAction, AppDispatch>([thunk]);
|
const mockStore = configureMockStore<typeof rootState, AnyAction, AppDispatch>([thunk]);
|
||||||
|
|
||||||
/** Apply actions to the state, one at a time. */
|
/** Apply actions to the state, one at a time. */
|
||||||
|
@ -29,12 +30,13 @@ const createTestStore = (initialState: any) => createStore(rootReducer, initialS
|
||||||
|
|
||||||
const TestApp: FC<any> = ({ children, storeProps, routerProps = {} }) => {
|
const TestApp: FC<any> = ({ children, storeProps, routerProps = {} }) => {
|
||||||
let store: any;
|
let store: any;
|
||||||
|
let appState = rootState;
|
||||||
|
|
||||||
if (storeProps) {
|
if (storeProps) {
|
||||||
rootState = merge(rootState, storeProps);
|
appState = merge(rootState, storeProps);
|
||||||
store = createTestStore(rootState);
|
store = createTestStore(appState);
|
||||||
} else {
|
} else {
|
||||||
store = createTestStore(rootState);
|
store = createTestStore(appState);
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
|
|
Loading…
Reference in New Issue