Download react-hook-form/src/__tests__/logic/isWatched.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 3.05 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/src/__tests__/logic/isWatched.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-hook-form/src/__tests__/logic/isWatched.test.ts
-
curl -L -o isWatched.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/src/__tests__/logic/isWatched.test.ts
3.05 kB
| import isWatched from '../../logic/isWatched'; | |
| describe('isWatched', () => { | |
| it('should return watched fields', () => { | |
| expect( | |
| isWatched('', { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(), | |
| focus: '', | |
| watchAll: true, | |
| }), | |
| ).toBeTruthy(); | |
| expect( | |
| isWatched('test', { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(['test']), | |
| focus: '', | |
| watchAll: false, | |
| }), | |
| ).toBeTruthy(); | |
| }); | |
| it('should return true when watched with parent node', () => { | |
| expect( | |
| isWatched('test.test', { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(['test']), | |
| focus: '', | |
| watchAll: false, | |
| }), | |
| ).toBeTruthy(); | |
| expect( | |
| isWatched('test.test.test', { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(['test.test']), | |
| focus: '', | |
| watchAll: false, | |
| }), | |
| ).toBeTruthy(); | |
| expect( | |
| isWatched('test.test.test', { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(['testFail.test', 'test.test']), | |
| focus: '', | |
| watchAll: false, | |
| }), | |
| ).toBeTruthy(); | |
| expect( | |
| isWatched('test.0', { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(['test']), | |
| focus: '', | |
| watchAll: false, | |
| }), | |
| ).toBeTruthy(); | |
| expect( | |
| isWatched('test.0.test', { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(['test.0']), | |
| focus: '', | |
| watchAll: false, | |
| }), | |
| ).toBeTruthy(); | |
| }); | |
| it("should return false when watched with parent node that doesn't match child name", () => { | |
| expect( | |
| isWatched('test.test.test', { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(['tesk.test']), | |
| focus: '', | |
| watchAll: false, | |
| }), | |
| ).toBeFalsy(); | |
| expect( | |
| isWatched('test.test.test', { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(['testFail.test']), | |
| focus: '', | |
| watchAll: false, | |
| }), | |
| ).toBeFalsy(); | |
| }); | |
| it('should return falsy for blur event', () => { | |
| expect( | |
| isWatched( | |
| '', | |
| { | |
| mount: new Set(), | |
| disabled: new Set(), | |
| unMount: new Set(), | |
| array: new Set(), | |
| watch: new Set(), | |
| focus: '', | |
| watchAll: true, | |
| }, | |
| true, | |
| ), | |
| ).toBeFalsy(); | |
| }); | |
| }); | |