October 2019
Intermediate to advanced
426 pages
11h 49m
English
Similarly to how we tested the useUserState Hook, we can also test the usePostsState Hook.
Let's test the usePostsState Hook now:
import { renderHook, act } from '@testing-library/react-hooks'import { StateContextWrapper } from './testUtils'import useDispatch from './useDispatch'import usePostsState from './usePostsState'
test('should use posts state', () => { const { result } = renderHook( () => usePostsState(), { wrapper: StateContextWrapper } ) expect(result.current).toEqual([])})
Read now
Unlock full access