Extract and set form values through the DOM—no frameworks required! https://github.com/TheoryOfNekomata/formxtra
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

42 lignes
1.7 KiB

  1. /// <reference types="cypress" />
  2. /// <reference types="cypress-jest-adapter" />
  3. import getFormValues from '../../src'
  4. import * as utils from '../utils';
  5. describe('blank template', () => {
  6. beforeEach(utils.setup('everything'))
  7. it('should have blank form value', () => {
  8. utils.test(
  9. (cy) => {
  10. cy.get('[name="first_name"]').type('John')
  11. cy.get('[name="middle_name"]').type('Marcelo')
  12. cy.get('[name="last_name"]').type('Dela Cruz')
  13. cy.get('[name="gender"][value="m"]').check()
  14. cy.get('[name="civil_status"]').select('Married')
  15. cy.get('[name="new_registration"]').check()
  16. cy.get('[name="nationality"][value="filipino"]').check()
  17. cy.get('[name="dependent"][value="Jun"]').check()
  18. // Note: JSDOM is static for now
  19. cy.get('button.dependents').click()
  20. cy.get('.additional-dependent [name="dependent"][type="text"]').last().type('Juana')
  21. cy.get('button.dependents').click()
  22. cy.get('.additional-dependent [name="dependent"][type="text"]').last().type('Jane')
  23. cy.get('button.dependents').click()
  24. cy.get('.additional-dependent [name="dependent"][type="text"]').last().type('Josh')
  25. cy.get('[name="notes"]').type('Test content\n\nNew line\n\nAnother line')
  26. return cy.get('[name="submit"][value="Hi"]')
  27. },
  28. (form: HTMLFormElement, submitter: any, search: any) => {
  29. const before = utils.makeSearchParams(getFormValues(form, submitter)).toString();
  30. const after = utils.makeSearchParams(search).toString();
  31. expect(before).toEqual(after);
  32. },
  33. 'first_name=John&middle_name=Marcelo&last_name=Dela+Cruz&gender=m&civil_status=married&new_registration=on&nationality=filipino&dependent=Jun&notes=Test+content%0D%0A%0D%0ANew+line%0D%0A%0D%0AAnother+line&submit=Hi',
  34. );
  35. });
  36. })