Extract and set form values through the DOM—no frameworks required! https://github.com/TheoryOfNekomata/formxtra
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /// <reference types="cypress" />
  2. import getFormValues from '../../src'
  3. import * as utils from '../utils';
  4. describe('single input template', () => {
  5. beforeEach(utils.setup('single-input'))
  6. it('should have single form value', () => {
  7. utils.test(
  8. (cy: any) => cy.get('[type="submit"]'),
  9. (form: HTMLFormElement, submitter: any, search: any) => {
  10. const before = utils.makeSearchParams(getFormValues(form, submitter)).toString();
  11. const after = utils.makeSearchParams(search).toString();
  12. expect(before).toEqual(after);
  13. },
  14. {
  15. hello: 'Hi',
  16. }
  17. );
  18. });
  19. })
  20. describe('single readonly template', () => {
  21. beforeEach(utils.setup('single-readonly-input'))
  22. it('should have single form value', () => {
  23. utils.test(
  24. (cy: any) => cy.get('[type="submit"]'),
  25. (form: HTMLFormElement, submitter: any, search: any) => {
  26. const before = utils.makeSearchParams(getFormValues(form, submitter)).toString();
  27. const after = utils.makeSearchParams(search).toString();
  28. expect(before).toEqual(after);
  29. },
  30. {
  31. hello: 'Hi',
  32. }
  33. );
  34. });
  35. })
  36. describe('single disabled template', () => {
  37. beforeEach(utils.setup('single-disabled-input'))
  38. it('should have blank form value', () => {
  39. utils.test(
  40. (cy: any) => cy.get('[type="submit"]'),
  41. (form: HTMLFormElement, submitter: any, search: any) => {
  42. const before = utils.makeSearchParams(getFormValues(form, submitter)).toString();
  43. const after = utils.makeSearchParams(search).toString();
  44. expect(before).toEqual(after);
  45. },
  46. {}
  47. );
  48. });
  49. })
  50. describe('single input with double button submitters template', () => {
  51. beforeEach(utils.setup('single-input-with-double-button-submitters'))
  52. it('should have double form values', () => {
  53. utils.test(
  54. (cy: any) => cy.get('[name="action"][value="Foo"]'),
  55. (form: HTMLFormElement, submitter: any, search: any) => {
  56. const before = utils.makeSearchParams(getFormValues(form, submitter)).toString();
  57. const after = utils.makeSearchParams(search).toString();
  58. expect(before).toEqual(after);
  59. },
  60. {
  61. hello: 'Hi',
  62. action: 'Foo',
  63. }
  64. );
  65. });
  66. })
  67. describe('single input with double input submitters template', () => {
  68. beforeEach(utils.setup('single-input-with-double-input-submitters'))
  69. it('should have double form values', () => {
  70. utils.test(
  71. (cy: any) => cy.get('[name="action"][value="Bar"]'),
  72. (form: HTMLFormElement, submitter: any, search: any) => {
  73. const before = utils.makeSearchParams(getFormValues(form, submitter)).toString();
  74. const after = utils.makeSearchParams(search).toString();
  75. expect(before).toEqual(after);
  76. },
  77. {
  78. hello: 'Hi',
  79. action: 'Bar',
  80. }
  81. );
  82. });
  83. })