/
githubmirror
/
react-hook-form
Обзор
Документация
Войти
/
githubmirror
/
react-hook-form
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/__tests__/logic/getEventValue.test.ts
33 строки
1 KB
bill
🧪 add test for enhance getEventValue to handle file inputs (#13289)
18 июл 2026, 08:59
Не верифицирован
18 июл 2026, 08:59
d920e93
Код
Авторство
О чём код?
import getEventValue from '../../logic/getEventValue'; test('getEventValue should return correct value', () => { expect( getEventValue({ target: { checked: true, type: 'checkbox' }, }), ).toEqual(true); expect( getEventValue({ target: { checked: true, type: 'checkbox', value: 'test' }, }), ).toEqual(true); expect(getEventValue({ target: { value: 'test' }, type: 'test' })).toEqual( 'test', ); expect(getEventValue({ data: 'test' })).toEqual({ data: 'test' }); expect(getEventValue('test')).toEqual('test'); expect(getEventValue(undefined)).toEqual(undefined); expect(getEventValue(null)).toEqual(null); }); test('getEventValue should return files for a file input target', () => { const files = [new File(['hello'], 'hello.png', { type: 'image/png' })]; expect( getEventValue({ target: { type: 'file', files, value: 'C:\\fakepath\\hello.png' }, }), ).toEqual(files); expect(getEventValue({ target: { type: 'file', files: [] } })).toEqual([]); });