Merge branch 'INDA-330-pii-update' into 'main'
[ProtonMail-WebClient.git] / packages / testing / lib / mockUseSelector.ts
blob81df9f98fa76032b78662e0ae0ef2e8cf113a83c
1 import * as useSelectorModule from 'react-redux';
3 // A simple workaround for jest issue not solved yet
4 // https://stackoverflow.com/questions/67872622/jest-spyon-not-working-on-index-file-cannot-redefine-property
5 jest.mock('react-redux', () => {
6     return {
7         __esModule: true,
8         ...jest.requireActual('react-redux'),
9     };
10 });
12 export const mockUseSelector = (value?: Partial<ReturnType<typeof useSelectorModule.useSelector>>) => {
13     const mockedUseSelector = jest.spyOn(useSelectorModule, 'useSelector');
14     mockedUseSelector.mockReturnValue(value);
15     return mockedUseSelector;