Extract and set form values through the DOM—no frameworks required! https://github.com/TheoryOfNekomata/formxtra
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

everything.test.ts 1.6 KiB

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