import { getFormValues, setFormValues } from '../../src'; import * as utils from '../utils' describe('date', () => { describe('basic', () => { beforeEach(utils.setup(` Datetime-Local/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: '2003-04-06T13:37', }, }); }); }) describe('disabled', () => { beforeEach(utils.setup(` Datetime-Local/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(` Datetime-Local/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: '2003-04-20T13:37', }, }); }); }); describe('readonly', () => { beforeEach(utils.setup(` Datetime-Local/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: '2003-11-11T13:37', }, }); }); }); describe('programmatic value setting', () => { beforeEach(utils.setup(` Datetime-Local/Programmatic Value Setting
`)); it('should have form values set', () => { utils.test({ action: (cy: any) => cy.get('[type="submit"]'), preAction: (form: HTMLFormElement) => { setFormValues(form, { hello: new Date('2000-01-01T13: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: '2000-01-01T13:37', }, }); }); }); describe('duplicate', () => { beforeEach(utils.setup(` Datetime-Local/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: ['2007-07-07T13:37', '2008-08-08T13:37'], }, }); }); it('should set both values', () => { utils.test({ preAction: (form: HTMLFormElement) => { setFormValues(form, { hello: ['2006-06-06T13:37', '2005-05-05T13:37'], }) }, 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: ['2006-06-06T13:37', '2005-05-05T13:37'], }, }); }); }); })