Download react-hook-form/src/__tests__/logic/getValidateError.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 953 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/__tests__/logic/getValidateError.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/__tests__/logic/getValidateError.test.ts
-
curl -L -o getValidateError.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/__tests__/logic/getValidateError.test.ts
953 Bytes
| 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(); | |
| }); | |
| }); | |