diff --git a/cypress/integration/fieldset.test.ts b/cypress/integration/fieldset.test.ts new file mode 100644 index 0000000..137d36e --- /dev/null +++ b/cypress/integration/fieldset.test.ts @@ -0,0 +1,164 @@ +import { getFormValues, setFormValues } from '../../src'; +import * as utils from '../utils' + +describe('fieldset', () => { + describe('basic', () => { + beforeEach(utils.setup(` + + + + + Text/Basic + + +
+
+ Fieldset + +
+ +
+ + + `)) + + it('should have single form value', () => { + utils.test({ + querySubmitter: (cy: any) => cy.get('[type="submit"]'), + onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { + const before = utils.makeSearchParams(getFormValues(form, { submitter })) + .toString(); + const after = utils.makeSearchParams(search) + .toString(); + expect(before) + .toEqual(after); + }, + expectedStaticValue: { + hello: 'Hi', + }, + }); + }); + }); + + describe('disabled', () => { + beforeEach(utils.setup(` + + + + + Text/Disabled + + +
+
+ Fieldset + +
+ +
+ + + `)) + + it('should have blank form value', () => { + utils.test({ + querySubmitter: (cy: any) => cy.get('[type="submit"]'), + onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { + const before = utils.makeSearchParams(getFormValues(form, { submitter })) + .toString(); + const after = utils.makeSearchParams(search) + .toString(); + expect(before) + .toEqual(after); + }, + expectedStaticValue: {}, + }); + }); + }) + + describe('outside', () => { + beforeEach(utils.setup(` + + + + + Text/Outside + + +
+ +
+
+ Fieldset + +
+ + + `)) + + it('should have single form value', () => { + utils.test({ + querySubmitter: (cy: any) => cy.get('[type="submit"]'), + onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { + const before = utils.makeSearchParams(getFormValues(form, { submitter })) + .toString(); + const after = utils.makeSearchParams(search) + .toString(); + expect(before) + .toEqual(after); + }, + expectedStaticValue: { + hello: 'Hi', + }, + }); + }); + }); + + describe('outside disabled', () => { + beforeEach(utils.setup(` + + + + + Text/Outside + + +
+ +
+
+ Fieldset + +
+ + + `)) + + it('should have blank form value', () => { + utils.test({ + querySubmitter: (cy: any) => cy.get('[type="submit"]'), + onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { + const before = utils.makeSearchParams(getFormValues(form, { submitter })) + .toString(); + const after = utils.makeSearchParams(search) + .toString(); + expect(before) + .toEqual(after); + }, + expectedStaticValue: {}, + }); + }); + }); +});