Created
June 30, 2022 20:34
-
-
Save nemrosim/0167043837c1867048b7552534b78b11 to your computer and use it in GitHub Desktop.
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 { renderHook, act } from '@testing-library/react-hooks'; | |
import { useSimplestHook } from './1.simplest-hook'; | |
it('should set to true', () => { | |
const { result } = renderHook(() => useSimplestHook()); | |
expect(result.current.isTrue).toBe(false); | |
act(() => { | |
result.current.toggle(); | |
}); | |
expect(result.current.isTrue).toBe(true); | |
}); | |
it('should set to true after 1 second', async () => { | |
const { result, waitForNextUpdate } = renderHook(() => useSimplestHook()); | |
expect(result.current.isTrue).toBe(false); | |
await waitForNextUpdate(); | |
expect(result.current.isTrue).toBe(true); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment