/
githubmirror
/
react-hook-form
Обзор
Документация
Войти
/
githubmirror
/
react-hook-form
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/__tests__/utils/live.test.ts
33 строки
985 B
HyeongHo Jun
🔩 test(utils): add unit tests for live function with Ref type (#12932)
04 июл 2025, 04:31
Не верифицирован
04 июл 2025, 04:31
898e196
Код
Авторство
О чём код?
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); }); });