import { getFormValues, setFormValues } from '../../src'; import * as utils from '../utils' describe('week', () => { describe('basic', () => { beforeEach(utils.setup(` Week/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-W25', }, }); }); }) describe('disabled', () => { beforeEach(utils.setup(` Week/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(` Week/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-W25', }, }); }); }); describe('readonly', () => { beforeEach(utils.setup(` Text/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-W25', }, }); }); }); describe('programmatic value setting', () => { beforeEach(utils.setup(` Week/Programmatic Value Setting
`)); it('should have form values set', () => { utils.test({ action: (cy: any) => cy.get('[type="submit"]'), preAction: (form: HTMLFormElement) => { setFormValues(form, { hello: '2003-W25', }) }, 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-W25', }, }); }); }); describe('duplicate', () => { beforeEach(utils.setup(` Week/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: ['2003-W25', '2003-W30'], }, }); }); it('should set both values', () => { utils.test({ preAction: (form: HTMLFormElement) => { setFormValues(form, { hello: ['2003-W40', '2003-W50'], }) }, 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-W40', '2003-W50'], }, }); }); }); })