October 2019
Intermediate to advanced
426 pages
11h 49m
English
Using the StateContextWrapper and the Dispatch Hook, we can now test the useUserState Hook by dispatching LOGIN and REGISTER actions and checking the result. To dispatch these actions, we use the act function from the testing library.
Let's test the useUserState Hook:
import { renderHook, act } from '@testing-library/react-hooks'import { StateContextWrapper } from './testUtils'import useDispatch from './useDispatch'import useUserState from './useUserState'
test('should use user state', () => { const ...Read now
Unlock full access