/
githubmirror
/
react-hook-form
Обзор
Документация
Войти
/
githubmirror
/
react-hook-form
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/__tests__/logic/getValidateError.test.ts
46 строк
953 B
Gromit (전민재)
✅ chore: add noop Utils Function (#11455)
03 фев 2024, 01:09
Не верифицирован
03 фев 2024, 01:09
5c3b4c0
Код
Авторство
О чём код?
import getValidateError from '../../logic/getValidateError'; import noop from '../../utils/noop'; describe('getValidateError', () => { it('should return field error in correct format', () => { expect( getValidateError( 'This is a required field', { name: 'test1', value: '', }, 'required', ), ).toEqual({ type: 'required', message: 'This is a required field', ref: { name: 'test1', value: '', }, }); expect( getValidateError( false, { name: 'test1', value: '', }, 'required', ), ).toEqual({ type: 'required', message: '', ref: { name: 'test1', value: '', }, }); }); it('should return undefined when called with non string result', () => { expect(getValidateError(undefined, noop)).toBeUndefined(); }); });