/
githubmirror
/
react-hook-form
Обзор
Документация
Войти
/
githubmirror
/
react-hook-form
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/__tests__/logic/unsetEmptyArray.test.ts
31 строка
740 B
HyeongHo Jun
🧪 test: add unit tests for unsetEmptyArray, isWeb, and getValidationModes (#12940)
13 июл 2025, 03:20
Не верифицирован
13 июл 2025, 03:20
7372556
Код
Авторство
О чём код?
import unsetEmptyArray from '../../logic/unsetEmptyArray'; import unset from '../../utils/unset'; jest.mock('../../utils/unset', () => ({ __esModule: true, default: jest.fn(), })); describe('unsetEmptyArray', () => { const mockedUnset = unset as jest.MockedFunction<typeof unset>; beforeAll(() => { mockedUnset.mockClear(); }); it('should call unset when the array is empty', () => { const ref = { foo: [] as unknown[] }; unsetEmptyArray(ref, 'foo'); expect(mockedUnset).toHaveBeenCalledWith(ref, 'foo'); }); it('should not call unset when the array is not empty', () => { const ref = { foo: ['data'] }; unsetEmptyArray(ref, 'foo'); expect(mockedUnset).not.toHaveBeenCalled(); }); });