import { getFormValues, setFormValues } from '../../src'; import * as utils from '../utils' describe('time', () => { describe('basic', () => { beforeEach(utils.setup(` Time/Basic
`)) it('should have single form value', () => { utils.test({ action: (cy: any) => cy.get('[type="submit"]'), test: (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: '13:37', }, }); }); }) describe('disabled', () => { beforeEach(utils.setup(` Time/Disabled
`)) it('should have blank form value', () => { utils.test({ action: (cy: any) => cy.get('[type="submit"]'), test: (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(` Time/Outside
`)) it('should have single form value', () => { utils.test({ action: (cy: any) => cy.get('[type="submit"]'), test: (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: '13:37', }, }); }); }); describe('readonly', () => { beforeEach(utils.setup(` Time/Readonly
`)) it('should have single form value', () => { utils.test({ action: (cy: any) => cy.get('[type="submit"]'), test: (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: '13:37', }, }); }); }); describe('programmatic value setting', () => { beforeEach(utils.setup(` Time/Programmatic Value Setting
`)); it('should have form values set', () => { utils.test({ action: (cy: any) => cy.get('[type="submit"]'), preAction: (form: HTMLFormElement) => { setFormValues(form, { hello: '13:37', }) }, test: (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: '13:37', }, }); }); }); describe('duplicate', () => { beforeEach(utils.setup(` Time/Duplicate
`)); it('should get both values', () => { utils.test({ action: (cy: any) => cy.get('[type="submit"]'), test: (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: ['13:37', '06:09'], }, }); }); it('should set both values', () => { utils.test({ preAction: (form: HTMLFormElement) => { setFormValues(form, { hello: ['04:20', '05:30'], }) }, action: (cy: any) => cy.get('[type="submit"]'), test: (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: ['04:20', '05:30'], }, }); }); }); })