Download react-hook-form/src/__tests__/logic/getRadioValue.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/src/__tests__/logic/getRadioValue.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-hook-form/src/__tests__/logic/getRadioValue.test.ts
-
curl -L -o getRadioValue.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/src/__tests__/logic/getRadioValue.test.ts
1.33 kB
| import getRadioValue from '../../logic/getRadioValue'; | |
| describe('getRadioValue', () => { | |
| it('should return default value if not valid or empty options', () => { | |
| expect(getRadioValue(undefined)).toEqual({ | |
| isValid: false, | |
| value: null, | |
| }); | |
| }); | |
| it('should return valid to true when value found', () => { | |
| expect( | |
| getRadioValue([ | |
| { name: 'bill', checked: false, value: '1' } as HTMLInputElement, | |
| { name: 'bill', checked: true, value: '2' } as HTMLInputElement, | |
| ]), | |
| ).toEqual({ | |
| isValid: true, | |
| value: '2', | |
| }); | |
| }); | |
| it('should return disabled input correctly', () => { | |
| expect( | |
| getRadioValue([ | |
| { | |
| name: 'bill', | |
| checked: false, | |
| value: '1', | |
| disabled: true, | |
| } as HTMLInputElement, | |
| { name: 'bill', checked: true, value: '2' } as HTMLInputElement, | |
| ]), | |
| ).toEqual({ | |
| isValid: true, | |
| value: '2', | |
| }); | |
| expect( | |
| getRadioValue([ | |
| { | |
| name: 'bill', | |
| checked: false, | |
| value: '1', | |
| } as HTMLInputElement, | |
| { | |
| name: 'bill', | |
| checked: true, | |
| disabled: true, | |
| value: '2', | |
| } as HTMLInputElement, | |
| ]), | |
| ).toEqual({ | |
| isValid: false, | |
| value: null, | |
| }); | |
| }); | |
| }); | |