Download react-hook-form/src/__tests__/utils/live.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 985 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/src/__tests__/utils/live.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-hook-form/src/__tests__/utils/live.test.ts
-
curl -L -o live.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/src/__tests__/utils/live.test.ts
985 Bytes
| import type { Ref } from '../../types'; | |
| import isHTMLElement from '../../utils/isHTMLElement'; | |
| import live from '../../utils/live'; | |
| jest.mock('../../utils/isHTMLElement'); | |
| const mockIsHTMLElement = isHTMLElement as jest.MockedFunction< | |
| typeof isHTMLElement | |
| >; | |
| describe('live', () => { | |
| afterEach(() => { | |
| jest.resetAllMocks(); | |
| }); | |
| it('should return true when ref is HTMLElement and connected', () => { | |
| mockIsHTMLElement.mockReturnValue(true); | |
| const ref: Ref = { isConnected: true, name: 'mock' }; | |
| expect(live(ref)).toBe(true); | |
| }); | |
| it('should return false when ref is not connected', () => { | |
| mockIsHTMLElement.mockReturnValue(true); | |
| const ref: Ref = { isConnected: false, name: 'mock' }; | |
| expect(live(ref)).toBe(false); | |
| }); | |
| it('should return false when ref is not an HTMLElement', () => { | |
| mockIsHTMLElement.mockReturnValue(false); | |
| const ref: Ref = { isConnected: false, name: 'mock' }; | |
| expect(live(ref)).toBe(false); | |
| }); | |
| }); | |