import { getFormValues } from '../../src' import * as utils from '../utils' describe('submitter', () => { describe('button', () => { beforeEach(utils.setup(` Submitter/Button
`)) it('should have double form values', () => { utils.test({ actionBeforeSubmit: (cy: any) => cy.get('[name="action"][value="Foo"]'), 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', action: 'Foo', }, }); }); }) describe('input', () => { beforeEach(utils.setup(` Submitter/Input
`)) it('should have double form values', () => { utils.test({ actionBeforeSubmit: (cy: any) => cy.get('[name="action"][value="Bar"]'), 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', action: 'Bar', }, }); }); }) describe('outside', () => { beforeEach(utils.setup(` Submitter/Outside
`)) it('should have single form value', () => { utils.test({ actionBeforeSubmit: (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', }, }); }); }) })