This commit is contained in:
Nathan Bierema 2024-08-05 22:58:55 -04:00
parent 5d0a50ba3c
commit d3e8df0c82
2 changed files with 11 additions and 7 deletions

View File

@ -1,6 +1,6 @@
import React from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import { createStore, applyMiddleware, Reducer } from 'redux';
import { render, screen, within } from '@testing-library/react';
import App from '../src/containers/App';
import { exportStateMiddleware } from '../src/middlewares/exportState';
@ -8,6 +8,7 @@ import { coreReducers } from '../src/reducers';
import { DATA_TYPE_KEY } from '../src/constants/dataTypes';
import { stringifyJSON } from '../src/utils/stringifyJSON';
import { combineReducers } from 'redux';
import { CoreStoreAction, CoreStoreState } from '../lib/types';
Object.defineProperty(window, 'matchMedia', {
writable: true,
@ -24,7 +25,11 @@ Object.defineProperty(window, 'matchMedia', {
});
const store = createStore(
combineReducers(coreReducers),
combineReducers(coreReducers) as Reducer<
CoreStoreState,
CoreStoreAction,
Partial<CoreStoreState>
>,
applyMiddleware(exportStateMiddleware),
);

View File

@ -1382,7 +1382,9 @@ describe('instrument', () => {
it('throws if reducer is not a function', () => {
expect(() =>
createStore(undefined as unknown as Reducer, instrument()),
).toThrow('Expected the reducer to be a function.');
).toThrow(
"Expected the root reducer to be a function. Instead, received: 'undefined'",
);
});
it('warns if the reducer is not a function but has a default field that is', () => {
@ -1396,10 +1398,7 @@ describe('instrument', () => {
instrument(),
),
).toThrow(
'Expected the reducer to be a function. ' +
'Instead got an object with a "default" field. ' +
'Did you pass a module instead of the default export? ' +
'Try passing require(...).default instead.',
"Expected the root reducer to be a function. Instead, received: 'object'",
);
});