Created
June 14, 2019 16:12
-
-
Save sliptype/b1ee5ba5774612e9ab8e946a1d6a2a36 to your computer and use it in GitHub Desktop.
Testing React components using Redux Hooks with Jest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render, cleanup } from '@testing-library/react'; | |
import { useSelector } from 'react-redux'; | |
import { when } from 'jest-when'; | |
import { getValue } from 'selectors'; | |
jest.mock('react-redux'); | |
afterEach(cleanup); | |
describe('Create Roll Job Modal', () => { | |
when(useSelector) | |
.calledWith(getValue) | |
.mockReturnValue(1); | |
it('Has value', async () => { | |
const { getByText } = render(<MyComponent />); | |
const rollButton = getByText('Roll Properties'); | |
expect(getByText('1')); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment