Download react-hook-form/cypress/e2e/reValidateMode.cy.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 5.39 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/cypress/e2e/reValidateMode.cy.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-hook-form/cypress/e2e/reValidateMode.cy.ts
-
curl -L -o reValidateMode.cy.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-hook-form/cypress/e2e/reValidateMode.cy.ts
5.39 kB
| describe('re-validate mode', () => { | |
| it('should re-validate the form only onSubmit with mode onSubmit and reValidateMode onSubmit', () => { | |
| cy.visit('http://localhost:3000/re-validate-mode/onSubmit/onSubmit'); | |
| cy.get('button#submit').click(); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="firstName"]').type('luo123456'); | |
| cy.get('input[name="lastName"]').type('luo12'); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('button#submit').click(); | |
| cy.get('p').should('have.length', 0); | |
| cy.get('#renderCount').contains('4'); | |
| }); | |
| it('should re-validate the form only onBlur with mode onSubmit and reValidateMode onBlur', () => { | |
| cy.visit('http://localhost:3000/re-validate-mode/onSubmit/onBlur'); | |
| cy.get('input[name="firstName"]').focus(); | |
| cy.get('input[name="firstName"]').blur(); | |
| cy.get('input[name="lastName"]').focus(); | |
| cy.get('input[name="lastName"]').blur(); | |
| cy.get('p').should('have.length', 0); | |
| cy.get('button#submit').click(); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="firstName"]').type('luo123456'); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="firstName"]').blur(); | |
| cy.get('input[name="lastName"]').type('luo12'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="lastName"]').blur(); | |
| cy.get('p').should('have.length', 0); | |
| cy.get('#renderCount').contains('5'); | |
| }); | |
| it('should re-validate the form only onSubmit with mode onBlur and reValidateMode onSubmit', () => { | |
| cy.visit('http://localhost:3000/re-validate-mode/onBlur/onSubmit'); | |
| cy.get('button#submit').click(); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="firstName"]').type('luo123456'); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="firstName"]').blur(); | |
| cy.get('input[name="lastName"]').type('luo12'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="lastName"]').blur(); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('button#submit').click(); | |
| cy.get('p').should('have.length', 0); | |
| cy.get('#renderCount').contains('4'); | |
| }); | |
| it('should re-validate the form only onSubmit with mode onChange and reValidateMode onSubmit', () => { | |
| cy.visit('http://localhost:3000/re-validate-mode/onChange/onSubmit'); | |
| cy.get('button#submit').click(); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="firstName"]').type('luo123456'); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"]').type('luo12'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('button#submit').click(); | |
| cy.get('p').should('have.length', 0); | |
| cy.get('#renderCount').contains('4'); | |
| }); | |
| it('should re-validate the form onBlur only with mode onBlur and reValidateMode onBlur', () => { | |
| cy.visit('http://localhost:3000/re-validate-mode/onBlur/onBlur'); | |
| cy.get('input[name="firstName"]').focus(); | |
| cy.get('input[name="firstName"]').blur(); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"]').focus(); | |
| cy.get('input[name="lastName"]').blur(); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="firstName"]').type('luo123456'); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="firstName"]').blur(); | |
| cy.get('input[name="lastName"]').type('luo12'); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="lastName"]').blur(); | |
| cy.get('p').should('have.length', 0); | |
| cy.get('#renderCount').contains('6'); | |
| }); | |
| it('should re-validate the form onChange with mode onBlur and reValidateMode onChange', () => { | |
| cy.visit('http://localhost:3000/re-validate-mode/onBlur/onChange'); | |
| cy.get('input[name="firstName"]').focus(); | |
| cy.get('input[name="firstName"]').blur(); | |
| cy.get('input[name="firstName"] + p').contains('firstName error'); | |
| cy.get('input[name="lastName"]').focus(); | |
| cy.get('input[name="lastName"]').blur(); | |
| cy.get('input[name="lastName"] + p').contains('lastName error'); | |
| cy.get('input[name="firstName"]').clear(); | |
| cy.get('input[name="lastName"]').clear(); | |
| cy.get('button#submit').click(); | |
| cy.get('input[name="firstName"]').type('luo123456'); | |
| cy.get('input[name="lastName"]').type('luo12'); | |
| cy.get('p').should('have.length', 0); | |
| cy.get('#renderCount').contains('7'); | |
| }); | |
| }); | |