Download react-use/tests/useFirstMountState.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 691 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/tests/useFirstMountState.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/tests/useFirstMountState.test.ts
-
curl -L -o useFirstMountState.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/tests/useFirstMountState.test.ts
691 Bytes
| import { renderHook } from '@testing-library/react-hooks'; | |
| import { useFirstMountState } from '../src'; | |
| describe('useFirstMountState', () => { | |
| it('should be defined', () => { | |
| expect(useFirstMountState).toBeDefined(); | |
| }); | |
| it('should return boolean', () => { | |
| expect(renderHook(() => useFirstMountState()).result.current).toEqual(expect.any(Boolean)); | |
| }); | |
| it('should return true on first render and false on all others', () => { | |
| const hook = renderHook(() => useFirstMountState()); | |
| expect(hook.result.current).toBe(true); | |
| hook.rerender(); | |
| expect(hook.result.current).toBe(false); | |
| hook.rerender(); | |
| expect(hook.result.current).toBe(false); | |
| }); | |
| }); | |