Extract and set form values through the DOM—no frameworks required! https://github.com/TheoryOfNekomata/formxtra
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

43 wiersze
1.6 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. let submitter: HTMLButtonElement
  9. utils.test(
  10. (cy) => {
  11. cy.get('[name="first_name"]').type('John')
  12. cy.get('[name="middle_name"]').type('Marcelo')
  13. cy.get('[name="last_name"]').type('Dela Cruz')
  14. cy.get('[name="gender"][value="m"]').check()
  15. cy.get('[name="civil_status"]').select('Married')
  16. cy.get('[name="new_registration"]').check()
  17. cy.get('[name="nationality"][value="filipino"]').check()
  18. cy.get('[name="dependent"][value="Jun"]').check()
  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. cy.get('[name="submit"][value="Hi"]').then((submitterEl: any) => {
  27. [submitter] = Array.from(submitterEl) as HTMLButtonElement[];
  28. submitterEl.trigger('click');
  29. })
  30. },
  31. (form: HTMLFormElement, search: any) => {
  32. const before = utils.makeSearchParams(getFormValues(form, submitter)).toString();
  33. const after = new URLSearchParams(search).toString();
  34. expect(before).toEqual(after);
  35. },
  36. {}
  37. );
  38. });
  39. })