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

View File

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