Select Git revision
mockRedux.js
Forked from
SOFT Core / SOFT 260 / React Redux Starter Code
4 commits behind, 27 commits ahead of the upstream repository.
jackmnolley authored
mockRedux.js 386 B
export const mockDispatch = jest.fn().mockName('dispatch');
jest.mock('react-redux', () => ({
useSelector: jest.fn((selector) => {
if (selector.mock === undefined) {
throw new Error(`Call to unmocked selector ${selector.name}`);
}
return selector();
}).mockName('useSelector'),
useDispatch: jest.fn().mockName('useDispatch').mockReturnValue(mockDispatch),
}));