The clearFormValues method is implemented to be able to clear form values for selected fields. Tests are now separated from pre-submit to querying the submitter.master
@@ -8,7 +8,11 @@ | |||||
"@typescript-eslint/no-unsafe-argument": "off", | "@typescript-eslint/no-unsafe-argument": "off", | ||||
"@typescript-eslint/no-unsafe-member-access": "off", | "@typescript-eslint/no-unsafe-member-access": "off", | ||||
"@typescript-eslint/no-unsafe-return": "off", | "@typescript-eslint/no-unsafe-return": "off", | ||||
"@typescript-eslint/no-unsafe-call": "off" | |||||
"@typescript-eslint/no-unsafe-call": "off", | |||||
"no-param-reassign": ["error", { | |||||
"props": true, | |||||
"ignorePropertyModificationsForRegex": ["[Ee]l$"] | |||||
}] | |||||
}, | }, | ||||
"parserOptions": { | "parserOptions": { | ||||
"project": "./tsconfig.eslint.json" | "project": "./tsconfig.eslint.json" | ||||
@@ -147,6 +147,7 @@ These are all the exported methods in the library: | |||||
import { | import { | ||||
getFormValues, | getFormValues, | ||||
setFormValues, | setFormValues, | ||||
clearFormValues, | |||||
getValue, | getValue, | ||||
isElementValueIncludedInFormSubmit, | isElementValueIncludedInFormSubmit, | ||||
isFieldElement, | isFieldElement, | ||||
@@ -165,8 +166,10 @@ See the [documentation folder](https://code.modal.sh/TheoryOfNekomata/formxtra/s | |||||
on this library. | on this library. | ||||
You may need the [event-submitter-polyfill package](https://github.com/idea2app/event-submitter-polyfill) for browsers | You may need the [event-submitter-polyfill package](https://github.com/idea2app/event-submitter-polyfill) for browsers | ||||
that do not support the submitter property on submit events (such as Safari). The submitter element is needed for | |||||
that do not support the submitter property on submit events. The submitter element is needed for | |||||
tracking which button triggered a form submission, and it may contain `name` and `value` attributes which are used to | tracking which button triggered a form submission, and it may contain `name` and `value` attributes which are used to | ||||
add values to the form (such as specifying which action to take for the rest of the form values). | |||||
add values to the form (such as specifying which action to take for the rest of the form values). Refer to the | |||||
[usability table for `SubmitEvent.submitter`](https://caniuse.com/mdn-api_submitevent_submitter) to check if your target | |||||
browser is supported. | |||||
The sources are under the [MIT license](https://code.modal.sh/TheoryOfNekomata/formxtra/raw/branch/master/LICENSE). | The sources are under the [MIT license](https://code.modal.sh/TheoryOfNekomata/formxtra/raw/branch/master/LICENSE). |
@@ -24,7 +24,7 @@ describe('checkbox', () => { | |||||
it('should have no form values', () => { | it('should have no form values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
const before = utils.makeSearchParams(values) | const before = utils.makeSearchParams(values) | ||||
@@ -42,7 +42,7 @@ describe('checkbox', () => { | |||||
it('should have false checked value', () => { | it('should have false checked value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, | const values = getFormValues(form, | ||||
{ | { | ||||
@@ -79,7 +79,7 @@ describe('checkbox', () => { | |||||
it('should have single form value on a single field', () => { | it('should have single form value on a single field', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -127,7 +127,7 @@ describe('checkbox', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -149,7 +149,7 @@ describe('checkbox', () => { | |||||
enabled: ['hello 3', 'hello 4'], | enabled: ['hello 3', 'hello 4'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -190,7 +190,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: true, }) | setFormValues(form, { enabled: true, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('on'); | expect(values['enabled']).toBe('on'); | ||||
@@ -204,7 +204,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'true', }) | setFormValues(form, { enabled: 'true', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('on'); | expect(values['enabled']).toBe('on'); | ||||
@@ -218,7 +218,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'yes', }) | setFormValues(form, { enabled: 'yes', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('on'); | expect(values['enabled']).toBe('on'); | ||||
@@ -232,7 +232,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'on', }) | setFormValues(form, { enabled: 'on', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('on'); | expect(values['enabled']).toBe('on'); | ||||
@@ -246,7 +246,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: false, }) | setFormValues(form, { enabled: false, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -260,7 +260,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'false', }) | setFormValues(form, { enabled: 'false', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -274,7 +274,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'no', }) | setFormValues(form, { enabled: 'no', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -288,7 +288,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'off', }) | setFormValues(form, { enabled: 'off', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -302,7 +302,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 1, }) | setFormValues(form, { enabled: 1, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('on'); | expect(values['enabled']).toBe('on'); | ||||
@@ -316,7 +316,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: '1', }) | setFormValues(form, { enabled: '1', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('on'); | expect(values['enabled']).toBe('on'); | ||||
@@ -330,7 +330,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 0, }) | setFormValues(form, { enabled: 0, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -344,7 +344,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: '0', }) | setFormValues(form, { enabled: '0', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -358,7 +358,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: null, }) | setFormValues(form, { enabled: null, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -372,7 +372,7 @@ describe('checkbox', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'null', }) | setFormValues(form, { enabled: 'null', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -24,7 +24,7 @@ describe('color', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('color', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('color', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('color', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('color', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: '#c0ffee', }) | setFormValues(form, { hello: '#c0ffee', }) | ||||
}, | }, | ||||
@@ -225,7 +225,7 @@ describe('color', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -248,7 +248,7 @@ describe('color', () => { | |||||
hello: ['#333333', '#aaccee'], | hello: ['#333333', '#aaccee'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -3,7 +3,7 @@ import getFormValuesDeprecated, { | |||||
setFormValues, | setFormValues, | ||||
isFieldElement, | isFieldElement, | ||||
isElementValueIncludedInFormSubmit, | isElementValueIncludedInFormSubmit, | ||||
getValue, | |||||
getValue, clearFormValues, | |||||
} from '../../src'; | } from '../../src'; | ||||
import * as utils from '../utils' | import * as utils from '../utils' | ||||
@@ -26,7 +26,7 @@ describe('misc', () => { | |||||
it('should call console.warn for deprecated default import usage', () => { | it('should call console.warn for deprecated default import usage', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let consoleWarnCalled = false | let consoleWarnCalled = false | ||||
const defaultConsoleWarn = console.warn | const defaultConsoleWarn = console.warn | ||||
@@ -40,9 +40,28 @@ describe('misc', () => { | |||||
}); | }); | ||||
}); | }); | ||||
it('should call noop for deprecated default import usage when console is not found', () => { | |||||
utils.test({ | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | |||||
let consoleWarnCalled = false | |||||
const defaultConsoleWarn = console.warn | |||||
console.warn = (...args: unknown[]) => { | |||||
consoleWarnCalled = true | |||||
}; | |||||
const globalConsole = global.console; | |||||
global.console = undefined; | |||||
getFormValuesDeprecated(form, { submitter }); | |||||
expect(consoleWarnCalled).toBe(false); | |||||
global.console = globalConsole; | |||||
console.warn = defaultConsoleWarn; | |||||
}, | |||||
}); | |||||
}); | |||||
it('should throw an error when providing invalid argument type as form to getFormValues', () => { | it('should throw an error when providing invalid argument type as form to getFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -58,7 +77,7 @@ describe('misc', () => { | |||||
it('should throw an error when providing null as form to getFormValues', () => { | it('should throw an error when providing null as form to getFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -74,7 +93,7 @@ describe('misc', () => { | |||||
it('should throw an error when providing a different element type as form to getFormValues', () => { | it('should throw an error when providing a different element type as form to getFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -90,7 +109,7 @@ describe('misc', () => { | |||||
it('should throw an error when providing invalid argument type as form to setFormValues', () => { | it('should throw an error when providing invalid argument type as form to setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -106,7 +125,7 @@ describe('misc', () => { | |||||
it('should throw an error when providing null as form to setFormValues', () => { | it('should throw an error when providing null as form to setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -122,7 +141,7 @@ describe('misc', () => { | |||||
it('should throw an error when providing a different element type as form to setFormValues', () => { | it('should throw an error when providing a different element type as form to setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -138,7 +157,7 @@ describe('misc', () => { | |||||
it('should throw an error when providing invalid argument type as values to setFormValues', () => { | it('should throw an error when providing invalid argument type as values to setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -154,7 +173,7 @@ describe('misc', () => { | |||||
it('should not throw an error when providing null as form to setFormValues', () => { | it('should not throw an error when providing null as form to setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -170,7 +189,7 @@ describe('misc', () => { | |||||
it('should throw an error when providing undefined as form to setFormValues', () => { | it('should throw an error when providing undefined as form to setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -204,7 +223,7 @@ describe('misc', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -240,7 +259,7 @@ describe('misc', () => { | |||||
it('should check for valid field elements value', () => { | it('should check for valid field elements value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const meter = document.getElementById('meter'); | const meter = document.getElementById('meter'); | ||||
expect(getValue(meter)).toBe(5); | expect(getValue(meter)).toBe(5); | ||||
@@ -250,7 +269,7 @@ describe('misc', () => { | |||||
it('should check for invalid field elements value', () => { | it('should check for invalid field elements value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
expect(getValue(document.body)).toBe(null); | expect(getValue(document.body)).toBe(null); | ||||
}, | }, | ||||
@@ -259,7 +278,7 @@ describe('misc', () => { | |||||
it('should check for elements as included fields', () => { | it('should check for elements as included fields', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const input = document.getElementById('input'); | const input = document.getElementById('input'); | ||||
expect(isElementValueIncludedInFormSubmit(input)).toBe(true); | expect(isElementValueIncludedInFormSubmit(input)).toBe(true); | ||||
@@ -269,7 +288,7 @@ describe('misc', () => { | |||||
it('should check for elements as excluded fields', () => { | it('should check for elements as excluded fields', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const notField = document.getElementById('notField'); | const notField = document.getElementById('notField'); | ||||
expect(isElementValueIncludedInFormSubmit(notField)).toBe(false); | expect(isElementValueIncludedInFormSubmit(notField)).toBe(false); | ||||
@@ -283,7 +302,7 @@ describe('misc', () => { | |||||
it('should check for elements as valid for fields', () => { | it('should check for elements as valid for fields', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const input = document.getElementById('input'); | const input = document.getElementById('input'); | ||||
expect(isFieldElement(input)).toBe(true); | expect(isFieldElement(input)).toBe(true); | ||||
@@ -295,7 +314,7 @@ describe('misc', () => { | |||||
it('should check for elements as invalid for fields', () => { | it('should check for elements as invalid for fields', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const meter = document.getElementById('meter'); | const meter = document.getElementById('meter'); | ||||
expect(isFieldElement(meter)).toBe(false); | expect(isFieldElement(meter)).toBe(false); | ||||
@@ -325,7 +344,7 @@ describe('misc', () => { | |||||
it('should parse string values for setFormValues', () => { | it('should parse string values for setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -342,7 +361,7 @@ describe('misc', () => { | |||||
it('should parse entries values for setFormValues', () => { | it('should parse entries values for setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -359,7 +378,7 @@ describe('misc', () => { | |||||
it('should parse URLSearchParams values for setFormValues', () => { | it('should parse URLSearchParams values for setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -376,7 +395,7 @@ describe('misc', () => { | |||||
it('should parse object values for setFormValues', () => { | it('should parse object values for setFormValues', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
let isThrown = false; | let isThrown = false; | ||||
try { | try { | ||||
@@ -392,6 +411,52 @@ describe('misc', () => { | |||||
}); | }); | ||||
}); | }); | ||||
describe('clearing values', () => { | |||||
beforeEach(utils.setup(` | |||||
<!DOCTYPE html> | |||||
<html lang="en-PH"> | |||||
<head> | |||||
<meta charset="UTF-8"> | |||||
<title>Misc/Blank</title> | |||||
</head> | |||||
<body> | |||||
<form> | |||||
<input type="text" name="foobar" value="value1" /> | |||||
<input type="text" name="foobar" value="value2" /> | |||||
<input type="text" name="baz" value="value3" /> | |||||
<input type="text" name="bar" value="value1" /> | |||||
<input type="text" name="bar" value="value2" /> | |||||
<input type="radio" name="foo" value="value1" checked /> | |||||
<input type="radio" name="foo" value="value2" /> | |||||
<input type="radio" name="foo" value="value3" /> | |||||
<button type="submit">Submit</button> | |||||
</form> | |||||
</body> | |||||
</html> | |||||
`)); | |||||
it('should clear all values given a single key', () => { | |||||
utils.test({ | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | |||||
clearFormValues(form, 'foobar'); | |||||
expect(getFormValues(form)).toEqual({ foobar: ['', ''], baz: 'value3', bar: ['value1', 'value2'], foo: 'value1', }); | |||||
}, | |||||
}); | |||||
}); | |||||
it('should clear all values given multiple keys', () => { | |||||
utils.test({ | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | |||||
clearFormValues(form, ['foobar', 'bar', 'foo']); | |||||
expect(getFormValues(form)).toEqual({ foobar: ['', ''], baz: 'value3', bar: ['', ''], }); | |||||
}, | |||||
}); | |||||
}); | |||||
}); | |||||
describe('duplicates', () => { | describe('duplicates', () => { | ||||
beforeEach(utils.setup(` | beforeEach(utils.setup(` | ||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
@@ -416,7 +481,7 @@ describe('misc', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { foobar: ['foo', 'bar', 'baz']}) | setFormValues(form, { foobar: ['foo', 'bar', 'baz']}) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
expect(getFormValues(form)).toEqual({ foobar: ['foo', 'bar', 'baz'], }); | expect(getFormValues(form)).toEqual({ foobar: ['foo', 'bar', 'baz'], }); | ||||
}, | }, | ||||
@@ -24,7 +24,7 @@ describe('date', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -41,7 +41,7 @@ describe('date', () => { | |||||
it('should enable Date representation', () => { | it('should enable Date representation', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter, forceDateValues: true }); | const values = getFormValues(form, { submitter, forceDateValues: true }); | ||||
// somehow, checking instanceof Date fails here, because we're using an artificial date | // somehow, checking instanceof Date fails here, because we're using an artificial date | ||||
@@ -78,7 +78,7 @@ describe('date', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -114,7 +114,7 @@ describe('date', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -155,7 +155,7 @@ describe('date', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -193,7 +193,7 @@ describe('date', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: new Date('2000-01-01'), }) | setFormValues(form, { hello: new Date('2000-01-01'), }) | ||||
}, | }, | ||||
@@ -238,7 +238,7 @@ describe('date', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -260,7 +260,7 @@ describe('date', () => { | |||||
hello: ['2006-06-06', '2005-05-05'], | hello: ['2006-06-06', '2005-05-05'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('date', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -41,7 +41,7 @@ describe('date', () => { | |||||
it('should enable Date representation', () => { | it('should enable Date representation', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter, forceDateValues: true }); | const values = getFormValues(form, { submitter, forceDateValues: true }); | ||||
// somehow, checking instanceof Date fails here, because we're using an artificial date | // somehow, checking instanceof Date fails here, because we're using an artificial date | ||||
@@ -78,7 +78,7 @@ describe('date', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -114,7 +114,7 @@ describe('date', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -155,7 +155,7 @@ describe('date', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -193,7 +193,7 @@ describe('date', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: new Date('2000-01-01T13:37'), }) | setFormValues(form, { hello: new Date('2000-01-01T13:37'), }) | ||||
}, | }, | ||||
@@ -238,7 +238,7 @@ describe('date', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -260,7 +260,7 @@ describe('date', () => { | |||||
hello: ['2006-06-06T13:37', '2005-05-05T13:37'], | hello: ['2006-06-06T13:37', '2005-05-05T13:37'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('email', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('email', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('email', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('email', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('email', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 'email@example.com', }) | setFormValues(form, { hello: 'email@example.com', }) | ||||
}, | }, | ||||
@@ -225,7 +225,7 @@ describe('email', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -247,7 +247,7 @@ describe('email', () => { | |||||
hello: ['poppy@example.com', 'pumpkin@example.com'], | hello: ['poppy@example.com', 'pumpkin@example.com'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('file', () => { | |||||
it('should have no form values when no file is selected', () => { | it('should have no form values when no file is selected', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -41,13 +41,12 @@ describe('file', () => { | |||||
it('should have single form value when a file is selected', () => { | it('should have single form value when a file is selected', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => { | |||||
onBeforeSubmit: (cy) => { | |||||
cy | cy | ||||
.get('[name="hello"]') | .get('[name="hello"]') | ||||
.attachFile('uploads/data.json') | .attachFile('uploads/data.json') | ||||
return cy.get('[type="submit"]') | |||||
}, | }, | ||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -64,13 +63,12 @@ describe('file', () => { | |||||
it('should retrieve the file list upon setting appropriate option', () => { | it('should retrieve the file list upon setting appropriate option', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => { | |||||
onBeforeSubmit: (cy: any) => { | |||||
cy | cy | ||||
.get('[name="hello"]') | .get('[name="hello"]') | ||||
.attachFile('uploads/data.json') | .attachFile('uploads/data.json') | ||||
return cy.get('[type="submit"]') | |||||
}, | }, | ||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any) => { | ||||
const formValues = getFormValues(form, | const formValues = getFormValues(form, | ||||
{ | { | ||||
@@ -89,7 +87,7 @@ describe('file', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 'data.json' }); | setFormValues(form, { hello: 'data.json' }); | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any) => { | ||||
const formValues = getFormValues( | const formValues = getFormValues( | ||||
form, | form, | ||||
@@ -127,7 +125,7 @@ describe('file', () => { | |||||
it('should have no form values when no file is selected', () => { | it('should have no form values when no file is selected', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -144,13 +142,12 @@ describe('file', () => { | |||||
it('should have single form value when a file is selected', () => { | it('should have single form value when a file is selected', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => { | |||||
onBeforeSubmit: (cy: any) => { | |||||
cy | cy | ||||
.get('[name="hello"]') | .get('[name="hello"]') | ||||
.attachFile(['uploads/data.json', 'uploads/data2.json']) | .attachFile(['uploads/data.json', 'uploads/data2.json']) | ||||
return cy.get('[type="submit"]') | |||||
}, | }, | ||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -165,13 +162,12 @@ describe('file', () => { | |||||
it('should retrieve the file list upon setting appropriate option', () => { | it('should retrieve the file list upon setting appropriate option', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => { | |||||
onBeforeSubmit: (cy: any) => { | |||||
cy | cy | ||||
.get('[name="hello"]') | .get('[name="hello"]') | ||||
.attachFile(['uploads/data.json', 'uploads/data2.json']) | .attachFile(['uploads/data.json', 'uploads/data2.json']) | ||||
return cy.get('[type="submit"]') | |||||
}, | }, | ||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any) => { | ||||
const formValues = getFormValues(form, | const formValues = getFormValues(form, | ||||
{ | { | ||||
@@ -24,7 +24,7 @@ describe('hidden', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -62,7 +62,7 @@ describe('hidden', () => { | |||||
it('should have extra value for character set', () => { | it('should have extra value for character set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, includeCharset: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, includeCharset: true, })) | ||||
.toString(); | .toString(); | ||||
@@ -82,7 +82,7 @@ describe('hidden', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { _charset_: 'Shift-JIS' }); | setFormValues(form, { _charset_: 'Shift-JIS' }); | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, includeCharset: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, includeCharset: true, })) | ||||
.toString(); | .toString(); | ||||
@@ -123,7 +123,7 @@ describe('hidden', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -159,7 +159,7 @@ describe('hidden', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -197,7 +197,7 @@ describe('hidden', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 'Hi', }) | setFormValues(form, { hello: 'Hi', }) | ||||
}, | }, | ||||
@@ -242,7 +242,7 @@ describe('hidden', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -264,7 +264,7 @@ describe('hidden', () => { | |||||
hello: ['new value 1', 'another value 2'], | hello: ['new value 1', 'another value 2'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -20,7 +20,7 @@ describe('misc', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('misc', () => { | |||||
it('should have correct form values', () => { | it('should have correct form values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy) => { | |||||
onBeforeSubmit: (cy) => { | |||||
cy.get('[name="first_name"]') | cy.get('[name="first_name"]') | ||||
.type('John') | .type('John') | ||||
cy.get('[name="middle_name"]') | cy.get('[name="middle_name"]') | ||||
@@ -228,8 +228,8 @@ describe('misc', () => { | |||||
.trigger('change') | .trigger('change') | ||||
cy.get('[name="notes"]') | cy.get('[name="notes"]') | ||||
.type('Test content\n\nNew line\n\nAnother line') | .type('Test content\n\nNew line\n\nAnother line') | ||||
return cy.get('[name="submit"][value="Hi"]') | |||||
}, | }, | ||||
querySubmitter: (cy) => cy.get('[name="submit"][value="Hi"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -245,7 +245,8 @@ describe('misc', () => { | |||||
it('should have filled form values', () => { | it('should have filled form values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy) => cy.wait(3000).get('[name="submit"][value="Hi"]'), | |||||
onBeforeSubmit: (cy: any) => cy.wait(3000), | |||||
querySubmitter: (cy) => cy.get('[name="submit"][value="Hi"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('month', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -41,7 +41,7 @@ describe('month', () => { | |||||
it('should enable Date representation', () => { | it('should enable Date representation', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter, forceDateValues: true }); | const values = getFormValues(form, { submitter, forceDateValues: true }); | ||||
// somehow, checking instanceof Date fails here, because we're using an artificial date | // somehow, checking instanceof Date fails here, because we're using an artificial date | ||||
@@ -78,7 +78,7 @@ describe('month', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -114,7 +114,7 @@ describe('month', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -155,7 +155,7 @@ describe('month', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -193,7 +193,7 @@ describe('month', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: '2003-05', }) | setFormValues(form, { hello: '2003-05', }) | ||||
}, | }, | ||||
@@ -238,7 +238,7 @@ describe('month', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -260,7 +260,7 @@ describe('month', () => { | |||||
hello: ['2003-04', '2003-02'], | hello: ['2003-04', '2003-02'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('number', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, forceNumberValues: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, forceNumberValues: true, })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('number', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('number', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('number', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('number', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 5, }) | setFormValues(form, { hello: 5, }) | ||||
}, | }, | ||||
@@ -225,7 +225,7 @@ describe('number', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, forceNumberValues: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, forceNumberValues: true, })) | ||||
.toString(); | .toString(); | ||||
@@ -247,7 +247,7 @@ describe('number', () => { | |||||
hello: [4, 2], | hello: [4, 2], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('password', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('password', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('password', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('password', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('password', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 'Hi', }) | setFormValues(form, { hello: 'Hi', }) | ||||
}, | }, | ||||
@@ -225,7 +225,7 @@ describe('password', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -247,7 +247,7 @@ describe('password', () => { | |||||
hello: ['new value 1', 'another value 2'], | hello: ['new value 1', 'another value 2'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('radio', () => { | |||||
it('should have no form values', () => { | it('should have no form values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
const before = utils.makeSearchParams(values) | const before = utils.makeSearchParams(values) | ||||
@@ -63,7 +63,7 @@ describe('radio', () => { | |||||
it('should have single form value on a single field', () => { | it('should have single form value on a single field', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -111,7 +111,7 @@ describe('radio', () => { | |||||
it('should get last value as checked', () => { | it('should get last value as checked', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -133,7 +133,7 @@ describe('radio', () => { | |||||
enabled: ['hello 3', 'hello 4'], | enabled: ['hello 3', 'hello 4'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -183,7 +183,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: true, }) | setFormValues(form, { enabled: true, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -197,7 +197,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'true', }) | setFormValues(form, { enabled: 'true', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('true'); | expect(values['enabled']).toBe('true'); | ||||
@@ -211,7 +211,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'yes', }) | setFormValues(form, { enabled: 'yes', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('yes'); | expect(values['enabled']).toBe('yes'); | ||||
@@ -225,7 +225,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'on', }) | setFormValues(form, { enabled: 'on', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('on'); | expect(values['enabled']).toBe('on'); | ||||
@@ -239,7 +239,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: false, }) | setFormValues(form, { enabled: false, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -253,7 +253,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'false', }) | setFormValues(form, { enabled: 'false', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('false'); | expect(values['enabled']).toBe('false'); | ||||
@@ -267,7 +267,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'no', }) | setFormValues(form, { enabled: 'no', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('no') | expect(values['enabled']).toBe('no') | ||||
@@ -281,7 +281,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'off', }) | setFormValues(form, { enabled: 'off', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('off'); | expect(values['enabled']).toBe('off'); | ||||
@@ -295,7 +295,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 1, }) | setFormValues(form, { enabled: 1, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined(); | expect(values['enabled']).toBeUndefined(); | ||||
@@ -309,7 +309,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: '1', }) | setFormValues(form, { enabled: '1', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('1'); | expect(values['enabled']).toBe('1'); | ||||
@@ -323,7 +323,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 0, }) | setFormValues(form, { enabled: 0, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -337,7 +337,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: '0', }) | setFormValues(form, { enabled: '0', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('0') | expect(values['enabled']).toBe('0') | ||||
@@ -351,7 +351,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: null, }) | setFormValues(form, { enabled: null, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -365,7 +365,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: 'null', }) | setFormValues(form, { enabled: 'null', }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('null'); | expect(values['enabled']).toBe('null'); | ||||
@@ -379,7 +379,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: true, }) | setFormValues(form, { enabled: true, }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBeUndefined() | expect(values['enabled']).toBeUndefined() | ||||
@@ -393,7 +393,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: ['foo', 'bar', 'baz', 'on'], }) | setFormValues(form, { enabled: ['foo', 'bar', 'baz', 'on'], }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('on') | expect(values['enabled']).toBe('on') | ||||
@@ -407,7 +407,7 @@ describe('radio', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { enabled: ['foo', 'bar', 'baz', 'on', 'default', 'true'], }) | setFormValues(form, { enabled: ['foo', 'bar', 'baz', 'on', 'default', 'true'], }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const values = getFormValues(form, { submitter }) | const values = getFormValues(form, { submitter }) | ||||
expect(values['enabled']).toBe('true') | expect(values['enabled']).toBe('true') | ||||
@@ -24,7 +24,7 @@ describe('range', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, forceNumberValues: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, forceNumberValues: true, })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('range', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('range', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('range', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('range', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 5, }) | setFormValues(form, { hello: 5, }) | ||||
}, | }, | ||||
@@ -225,7 +225,7 @@ describe('range', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, forceNumberValues: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, forceNumberValues: true, })) | ||||
.toString(); | .toString(); | ||||
@@ -247,7 +247,7 @@ describe('range', () => { | |||||
hello: [4, 2], | hello: [4, 2], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('search', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -62,7 +62,7 @@ describe('search', () => { | |||||
it('should have extra value for directionality', () => { | it('should have extra value for directionality', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, includeDirectionality: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, includeDirectionality: true, })) | ||||
.toString(); | .toString(); | ||||
@@ -80,7 +80,7 @@ describe('search', () => { | |||||
it('should support other directionality', () => { | it('should support other directionality', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
document.getElementsByTagName('input')[0].style.direction = 'rtl'; | document.getElementsByTagName('input')[0].style.direction = 'rtl'; | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, includeDirectionality: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, includeDirectionality: true, })) | ||||
@@ -123,7 +123,7 @@ describe('search', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -159,7 +159,7 @@ describe('search', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -200,7 +200,7 @@ describe('search', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -238,7 +238,7 @@ describe('search', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 'Hi', }) | setFormValues(form, { hello: 'Hi', }) | ||||
}, | }, | ||||
@@ -283,7 +283,7 @@ describe('search', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -305,7 +305,7 @@ describe('search', () => { | |||||
hello: ['new value 1', 'another value 2'], | hello: ['new value 1', 'another value 2'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -29,7 +29,7 @@ describe('select', () => { | |||||
it('should have multiple form values on a single field', () => { | it('should have multiple form values on a single field', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -47,7 +47,7 @@ describe('select', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: ['Foo', 'Baz'] }); | setFormValues(form, { hello: ['Foo', 'Baz'] }); | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -94,7 +94,7 @@ describe('select', () => { | |||||
it('should have multiple form values on a single field', () => { | it('should have multiple form values on a single field', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -112,7 +112,7 @@ describe('select', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: ['Foo', 'Baz', 'Chocolate', 'Vanilla'] }) | setFormValues(form, { hello: ['Foo', 'Baz', 'Chocolate', 'Vanilla'] }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -130,7 +130,7 @@ describe('select', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: [['Foo', 'Baz', 'Chocolate'], ['Vanilla']] }) | setFormValues(form, { hello: [['Foo', 'Baz', 'Chocolate'], ['Vanilla']] }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -170,7 +170,7 @@ describe('select', () => { | |||||
it('should have single form value on a single field', () => { | it('should have single form value on a single field', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -220,7 +220,7 @@ describe('select', () => { | |||||
it('should have multiple form values on a single field', () => { | it('should have multiple form values on a single field', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -238,7 +238,7 @@ describe('select', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: ['Foo', 'Chocolate'] }) | setFormValues(form, { hello: ['Foo', 'Chocolate'] }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -256,7 +256,7 @@ describe('select', () => { | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: ['Foo', 'Ube'] }) | setFormValues(form, { hello: ['Foo', 'Ube'] }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -25,7 +25,7 @@ describe('submitter', () => { | |||||
it('should have double form values', () => { | it('should have double form values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[name="action"][value="Foo"]'), | |||||
querySubmitter: (cy: any) => cy.get('[name="action"][value="Foo"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('submitter', () => { | |||||
it('should have double form values', () => { | it('should have double form values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[name="action"][value="Bar"]'), | |||||
querySubmitter: (cy: any) => cy.get('[name="action"][value="Bar"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -103,7 +103,7 @@ describe('submitter', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('tel', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('tel', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('tel', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('tel', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('tel', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 'Hi', }) | setFormValues(form, { hello: 'Hi', }) | ||||
}, | }, | ||||
@@ -225,7 +225,7 @@ describe('tel', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -247,7 +247,7 @@ describe('tel', () => { | |||||
hello: ['new value 1', 'another value 2'], | hello: ['new value 1', 'another value 2'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('text', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -62,7 +62,7 @@ describe('text', () => { | |||||
it('should have extra value for directionality', () => { | it('should have extra value for directionality', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, includeDirectionality: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, includeDirectionality: true, })) | ||||
.toString(); | .toString(); | ||||
@@ -80,7 +80,7 @@ describe('text', () => { | |||||
it('should support other directionality', () => { | it('should support other directionality', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
document.getElementsByTagName('input')[0].style.direction = 'rtl'; | document.getElementsByTagName('input')[0].style.direction = 'rtl'; | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter, includeDirectionality: true, })) | const before = utils.makeSearchParams(getFormValues(form, { submitter, includeDirectionality: true, })) | ||||
@@ -123,7 +123,7 @@ describe('text', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -159,7 +159,7 @@ describe('text', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -200,7 +200,7 @@ describe('text', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -238,7 +238,7 @@ describe('text', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 'Hi', }) | setFormValues(form, { hello: 'Hi', }) | ||||
}, | }, | ||||
@@ -283,7 +283,7 @@ describe('text', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -305,7 +305,7 @@ describe('text', () => { | |||||
hello: ['new value 1', 'another value 2'], | hello: ['new value 1', 'another value 2'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('textarea', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('textarea', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('textarea', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('textarea', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('textarea', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 'Hi', }) | setFormValues(form, { hello: 'Hi', }) | ||||
}, | }, | ||||
@@ -221,7 +221,7 @@ describe('textarea', () => { | |||||
it('should read LF line breaks', () => { | it('should read LF line breaks', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => { | |||||
querySubmitter: (cy: any) => { | |||||
cy.get('[name="hello"]') | cy.get('[name="hello"]') | ||||
.type('Hi\nHello', { parseSpecialCharSequences: false }) | .type('Hi\nHello', { parseSpecialCharSequences: false }) | ||||
return cy.get('[type="submit"]') | return cy.get('[type="submit"]') | ||||
@@ -242,7 +242,7 @@ describe('textarea', () => { | |||||
it('should read CR line breaks', () => { | it('should read CR line breaks', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => { | |||||
querySubmitter: (cy: any) => { | |||||
cy.get('[name="hello"]') | cy.get('[name="hello"]') | ||||
.type('Hi\rHello', { parseSpecialCharSequences: false }) | .type('Hi\rHello', { parseSpecialCharSequences: false }) | ||||
return cy.get('[type="submit"]') | return cy.get('[type="submit"]') | ||||
@@ -263,7 +263,7 @@ describe('textarea', () => { | |||||
it('should read CRLF line breaks', () => { | it('should read CRLF line breaks', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => { | |||||
querySubmitter: (cy: any) => { | |||||
cy.get('[name="hello"]') | cy.get('[name="hello"]') | ||||
.type('Hi\r\nHello', { parseSpecialCharSequences: false }) | .type('Hi\r\nHello', { parseSpecialCharSequences: false }) | ||||
return cy.get('[type="submit"]') | return cy.get('[type="submit"]') | ||||
@@ -309,7 +309,7 @@ describe('textarea', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -331,7 +331,7 @@ describe('textarea', () => { | |||||
hello: ['new value 1', 'another value 2'], | hello: ['new value 1', 'another value 2'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('time', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('time', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('time', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('time', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('time', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: '13:37', }) | setFormValues(form, { hello: '13:37', }) | ||||
}, | }, | ||||
@@ -225,7 +225,7 @@ describe('time', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -247,7 +247,7 @@ describe('time', () => { | |||||
hello: ['04:20', '05:30'], | hello: ['04:20', '05:30'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('url', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('url', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('url', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('url', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('url', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: 'https://www.example.com', }) | setFormValues(form, { hello: 'https://www.example.com', }) | ||||
}, | }, | ||||
@@ -225,7 +225,7 @@ describe('url', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -247,7 +247,7 @@ describe('url', () => { | |||||
hello: ['https://foo.example.com', 'https://bar.example.com/context'], | hello: ['https://foo.example.com', 'https://bar.example.com/context'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -24,7 +24,7 @@ describe('week', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -65,7 +65,7 @@ describe('week', () => { | |||||
it('should have blank form value', () => { | it('should have blank form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -101,7 +101,7 @@ describe('week', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -142,7 +142,7 @@ describe('week', () => { | |||||
it('should have single form value', () => { | it('should have single form value', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -180,7 +180,7 @@ describe('week', () => { | |||||
it('should have form values set', () => { | it('should have form values set', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onLoaded: (form: HTMLFormElement) => { | onLoaded: (form: HTMLFormElement) => { | ||||
setFormValues(form, { hello: '2003-W25', }) | setFormValues(form, { hello: '2003-W25', }) | ||||
}, | }, | ||||
@@ -225,7 +225,7 @@ describe('week', () => { | |||||
it('should get both values', () => { | it('should get both values', () => { | ||||
utils.test({ | utils.test({ | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -247,7 +247,7 @@ describe('week', () => { | |||||
hello: ['2003-W40', '2003-W50'], | hello: ['2003-W40', '2003-W50'], | ||||
}) | }) | ||||
}, | }, | ||||
actionBeforeSubmit: (cy: any) => cy.get('[type="submit"]'), | |||||
querySubmitter: (cy: any) => cy.get('[type="submit"]'), | |||||
onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | onSubmitted: (form: HTMLFormElement, submitter: any, search: any) => { | ||||
const before = utils.makeSearchParams(getFormValues(form, { submitter })) | const before = utils.makeSearchParams(getFormValues(form, { submitter })) | ||||
.toString(); | .toString(); | ||||
@@ -8,7 +8,7 @@ type RetrieveSubmitterFn = (wrapper: typeof cy | JSDOMDummyCypress) => any | |||||
type HTMLSubmitterElement = HTMLButtonElement | HTMLInputElement | type HTMLSubmitterElement = HTMLButtonElement | HTMLInputElement | ||||
type TestFn = (form: HTMLFormElement, submitter: HTMLSubmitterElement, after: ExpectedSearchValue) => unknown | |||||
type TestFn = (form: HTMLFormElement, submitter?: HTMLSubmitterElement, after?: ExpectedSearchValue) => unknown | |||||
export const setup = (template: string) => { | export const setup = (template: string) => { | ||||
if (typeof cy !== 'undefined') { | if (typeof cy !== 'undefined') { | ||||
@@ -26,18 +26,20 @@ export const setup = (template: string) => { | |||||
} | } | ||||
type TestOptions = { | type TestOptions = { | ||||
actionBeforeSubmit: RetrieveSubmitterFn, | |||||
onSubmitted: TestFn, | |||||
querySubmitter: RetrieveSubmitterFn, | |||||
onSubmitted?: TestFn, | |||||
expectedStaticValue?: ExpectedSearchValue, | expectedStaticValue?: ExpectedSearchValue, | ||||
onLoaded?: Function, | |||||
onLoaded?: TestFn, | |||||
onBeforeSubmit?: RetrieveSubmitterFn, | |||||
} | } | ||||
export const test = (options: TestOptions) => { | export const test = (options: TestOptions) => { | ||||
const { | const { | ||||
actionBeforeSubmit: retrieveSubmitterFn, | |||||
onSubmitted: testFn, | |||||
querySubmitter, | |||||
onSubmitted, | |||||
expectedStaticValue, | expectedStaticValue, | ||||
onLoaded, | onLoaded, | ||||
onBeforeSubmit, | |||||
} = options; | } = options; | ||||
let form: HTMLFormElement | let form: HTMLFormElement | ||||
let submitter: HTMLButtonElement | HTMLInputElement | let submitter: HTMLButtonElement | HTMLInputElement | ||||
@@ -49,15 +51,13 @@ export const test = (options: TestOptions) => { | |||||
.then((formResult: any) => { | .then((formResult: any) => { | ||||
[form] = Array.from(formResult); | [form] = Array.from(formResult); | ||||
if (typeof onLoaded === 'function') { | |||||
onLoaded(form); | |||||
} | |||||
onLoaded?.(form); | |||||
}) | }) | ||||
r = retrieveSubmitterFn(cy) | |||||
.then((submitterQueryEl: any) => { | |||||
[submitter] = Array.from(submitterQueryEl as any[]) | |||||
}) | |||||
onBeforeSubmit?.(cy); | |||||
r = querySubmitter(cy).then((submitterQueryEl: any) => { | |||||
[submitter] = Array.from(submitterQueryEl as any[]) | |||||
}) | |||||
if (typeof expectedStaticValue !== 'undefined') { | if (typeof expectedStaticValue !== 'undefined') { | ||||
r.click() | r.click() | ||||
@@ -66,7 +66,7 @@ export const test = (options: TestOptions) => { | |||||
.location('search') | .location('search') | ||||
.then((search: any) => { | .then((search: any) => { | ||||
setTimeout(() => { | setTimeout(() => { | ||||
testFn(form, submitter, search) | |||||
onSubmitted?.(form, submitter, search) | |||||
}, 0) | }, 0) | ||||
}) | }) | ||||
} else { | } else { | ||||
@@ -74,21 +74,20 @@ export const test = (options: TestOptions) => { | |||||
.location('search') | .location('search') | ||||
.then((search: any) => { | .then((search: any) => { | ||||
setTimeout(() => { | setTimeout(() => { | ||||
testFn(form, submitter, search) | |||||
onSubmitted?.(form, submitter, search) | |||||
}, 0); | }, 0); | ||||
}) | }) | ||||
} | } | ||||
} else { | } else { | ||||
r = retrieveSubmitterFn(new JSDOMDummyCypress()) | |||||
const jsdomCy = new JSDOMDummyCypress() | |||||
onBeforeSubmit?.(jsdomCy); | |||||
r = querySubmitter(jsdomCy) | |||||
.then((submitterQueryEl: any) => { | .then((submitterQueryEl: any) => { | ||||
[submitter] = Array.from(submitterQueryEl as any[]); | [submitter] = Array.from(submitterQueryEl as any[]); | ||||
[form] = Array.from(window.document.getElementsByTagName('form')) | [form] = Array.from(window.document.getElementsByTagName('form')) | ||||
if (typeof onLoaded === 'function') { | |||||
onLoaded(form); | |||||
} | |||||
testFn(form, submitter, expectedStaticValue) | |||||
onLoaded?.(form); | |||||
onSubmitted?.(form, submitter, expectedStaticValue) | |||||
}) | }) | ||||
if (typeof expectedStaticValue !== 'undefined') { | if (typeof expectedStaticValue !== 'undefined') { | ||||
@@ -1,6 +1,6 @@ | |||||
{ | { | ||||
"name": "@theoryofnekomata/formxtra", | "name": "@theoryofnekomata/formxtra", | ||||
"version": "1.0.3", | |||||
"version": "1.0.4", | |||||
"files": [ | "files": [ | ||||
"dist", | "dist", | ||||
"src" | "src" | ||||
@@ -102,12 +102,10 @@ const setTextAreaFieldValue = ( | |||||
elementsOfSameName: HTMLTextAreaElement[], | elementsOfSameName: HTMLTextAreaElement[], | ||||
) => { | ) => { | ||||
if (Array.isArray(value) && elementsOfSameName.length > 1) { | if (Array.isArray(value) && elementsOfSameName.length > 1) { | ||||
// eslint-disable-next-line no-param-reassign | |||||
textareaEl.value = value[nthOfName]; | textareaEl.value = value[nthOfName]; | ||||
return; | return; | ||||
} | } | ||||
// eslint-disable-next-line no-param-reassign | |||||
textareaEl.value = value as string; | textareaEl.value = value as string; | ||||
}; | }; | ||||
@@ -146,7 +144,6 @@ const setSelectFieldValue = ( | |||||
// If this happens, all values must correspond to a <select multiple> element. | // If this happens, all values must correspond to a <select multiple> element. | ||||
const currentValue = valueArray[nthOfName] as string[]; | const currentValue = valueArray[nthOfName] as string[]; | ||||
Array.from(selectEl.options).forEach((el) => { | Array.from(selectEl.options).forEach((el) => { | ||||
// eslint-disable-next-line no-param-reassign | |||||
el.selected = currentValue.includes(el.value); | el.selected = currentValue.includes(el.value); | ||||
}); | }); | ||||
return; | return; | ||||
@@ -157,14 +154,12 @@ const setSelectFieldValue = ( | |||||
if (elementsOfSameName.some((el) => el.multiple)) { | if (elementsOfSameName.some((el) => el.multiple)) { | ||||
Array.from(selectEl.options).forEach((el) => { | Array.from(selectEl.options).forEach((el) => { | ||||
// eslint-disable-next-line no-param-reassign | |||||
el.selected = (value as string[]).includes(el.value); | el.selected = (value as string[]).includes(el.value); | ||||
}); | }); | ||||
return; | return; | ||||
} | } | ||||
Array.from(selectEl.options).forEach((el) => { | Array.from(selectEl.options).forEach((el) => { | ||||
// eslint-disable-next-line no-param-reassign | |||||
el.selected = el.value === (value as string[])[nthOfName]; | el.selected = el.value === (value as string[])[nthOfName]; | ||||
}); | }); | ||||
@@ -172,7 +167,6 @@ const setSelectFieldValue = ( | |||||
} | } | ||||
Array.from(selectEl.options).forEach((el) => { | Array.from(selectEl.options).forEach((el) => { | ||||
// eslint-disable-next-line no-param-reassign | |||||
el.selected = Array.isArray(value) | el.selected = Array.isArray(value) | ||||
? (value as string[]).includes(el.value) | ? (value as string[]).includes(el.value) | ||||
: el.value === value; | : el.value === value; | ||||
@@ -218,14 +212,12 @@ const setInputRadioFieldValue = ( | |||||
const valueWhenChecked = inputEl.getAttribute(ATTRIBUTE_VALUE); | const valueWhenChecked = inputEl.getAttribute(ATTRIBUTE_VALUE); | ||||
if (valueWhenChecked !== null) { | if (valueWhenChecked !== null) { | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.checked = ( | inputEl.checked = ( | ||||
Array.isArray(value) ? valueWhenChecked === value.slice(-1)[0] : valueWhenChecked === value | Array.isArray(value) ? valueWhenChecked === value.slice(-1)[0] : valueWhenChecked === value | ||||
); | ); | ||||
return; | return; | ||||
} | } | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.checked = ( | inputEl.checked = ( | ||||
Array.isArray(value) ? value.includes('on') : value === 'on' | Array.isArray(value) ? value.includes('on') : value === 'on' | ||||
); | ); | ||||
@@ -346,7 +338,6 @@ const setInputCheckboxFieldValue = ( | |||||
const valueWhenChecked = inputEl.getAttribute(ATTRIBUTE_VALUE); | const valueWhenChecked = inputEl.getAttribute(ATTRIBUTE_VALUE); | ||||
if (valueWhenChecked !== null) { | if (valueWhenChecked !== null) { | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.checked = ( | inputEl.checked = ( | ||||
Array.isArray(value) | Array.isArray(value) | ||||
? value.includes(valueWhenChecked) | ? value.includes(valueWhenChecked) | ||||
@@ -357,7 +348,6 @@ const setInputCheckboxFieldValue = ( | |||||
const newValue = parseBooleanValues(value); | const newValue = parseBooleanValues(value); | ||||
if (typeof newValue === 'boolean') { | if (typeof newValue === 'boolean') { | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.checked = newValue; | inputEl.checked = newValue; | ||||
} | } | ||||
}; | }; | ||||
@@ -472,7 +462,6 @@ const setInputNumericFieldValue = ( | |||||
elementsWithSameName: HTMLInputNumericElement[], | elementsWithSameName: HTMLInputNumericElement[], | ||||
) => { | ) => { | ||||
const valueArray = Array.isArray(value) ? value : [value]; | const valueArray = Array.isArray(value) ? value : [value]; | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.valueAsNumber = Number(valueArray[elementsWithSameName.length > 1 ? nthOfName : 0]); | inputEl.valueAsNumber = Number(valueArray[elementsWithSameName.length > 1 ? nthOfName : 0]); | ||||
}; | }; | ||||
@@ -579,7 +568,6 @@ const setInputDateLikeFieldValue = ( | |||||
const elementIndex = hasMultipleElementsOfSameName ? nthOfName : 0; | const elementIndex = hasMultipleElementsOfSameName ? nthOfName : 0; | ||||
if (inputEl.type.toLowerCase() === INPUT_TYPE_DATE) { | if (inputEl.type.toLowerCase() === INPUT_TYPE_DATE) { | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.value = new Date( | inputEl.value = new Date( | ||||
valueArray[elementIndex] as ConstructorParameters<typeof Date>[0], | valueArray[elementIndex] as ConstructorParameters<typeof Date>[0], | ||||
) | ) | ||||
@@ -589,7 +577,6 @@ const setInputDateLikeFieldValue = ( | |||||
} | } | ||||
if (inputEl.type.toLowerCase() === INPUT_TYPE_DATETIME_LOCAL) { | if (inputEl.type.toLowerCase() === INPUT_TYPE_DATETIME_LOCAL) { | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.value = new Date( | inputEl.value = new Date( | ||||
valueArray[elementIndex] as ConstructorParameters<typeof Date>[0], | valueArray[elementIndex] as ConstructorParameters<typeof Date>[0], | ||||
) | ) | ||||
@@ -598,7 +585,6 @@ const setInputDateLikeFieldValue = ( | |||||
} | } | ||||
if (inputEl.type.toLowerCase() === INPUT_TYPE_MONTH) { | if (inputEl.type.toLowerCase() === INPUT_TYPE_MONTH) { | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.value = new Date( | inputEl.value = new Date( | ||||
valueArray[elementIndex] as ConstructorParameters<typeof Date>[0], | valueArray[elementIndex] as ConstructorParameters<typeof Date>[0], | ||||
) | ) | ||||
@@ -765,12 +751,10 @@ const setInputHiddenFieldValue = ( | |||||
} | } | ||||
if (Array.isArray(value) && elementsWithSameName.length > 1) { | if (Array.isArray(value) && elementsWithSameName.length > 1) { | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.value = value[nthOfName]; | inputEl.value = value[nthOfName]; | ||||
return; | return; | ||||
} | } | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.value = value as string; | inputEl.value = value as string; | ||||
}; | }; | ||||
@@ -866,12 +850,10 @@ const setInputGenericFieldValue = ( | |||||
elementsWithSameName: HTMLInputElement[], | elementsWithSameName: HTMLInputElement[], | ||||
) => { | ) => { | ||||
if (Array.isArray(value) && elementsWithSameName.length > 1) { | if (Array.isArray(value) && elementsWithSameName.length > 1) { | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.value = value[nthOfName]; | inputEl.value = value[nthOfName]; | ||||
return; | return; | ||||
} | } | ||||
// eslint-disable-next-line no-param-reassign | |||||
inputEl.value = value as string; | inputEl.value = value as string; | ||||
}; | }; | ||||
@@ -1157,11 +1139,6 @@ export const getFormValues = (form: HTMLFormElement, options = {} as GetFormValu | |||||
...theFormValues, | ...theFormValues, | ||||
[fieldName]: fieldValue, | [fieldName]: fieldValue, | ||||
}; | }; | ||||
// return { | |||||
// ...theFormValues, | |||||
// [fieldName]: [...oldFormValue, fieldValue], | |||||
// }; | |||||
}, | }, | ||||
{} as Record<string, unknown>, | {} as Record<string, unknown>, | ||||
); | ); | ||||
@@ -1201,6 +1178,64 @@ const normalizeValues = (values: unknown): Record<string, unknown | unknown[]> = | |||||
return values as Record<string, unknown | unknown[]>; | return values as Record<string, unknown | unknown[]>; | ||||
}; | }; | ||||
/** | |||||
* Performs setting of form values. | |||||
* @param fieldElementEntries - Entries of field names and their corresponding elements. | |||||
* @param elementsWithSameName - Map of field names to elements or array of elements if they have | |||||
* duplicates. | |||||
* @param objectValues - Values to apply to the form. | |||||
*/ | |||||
const doSetFormValues = ( | |||||
fieldElementEntries: [string, HTMLElementWithName][], | |||||
elementsWithSameName: Record<string, HTMLElement[]>, | |||||
objectValues: Record<string, unknown>, | |||||
) => { | |||||
const nthElementOfName = {} as Record<string, number>; | |||||
fieldElementEntries | |||||
.forEach(([, el]) => { | |||||
nthElementOfName[el.name] = ( | |||||
typeof nthElementOfName[el.name] === 'number' | |||||
? nthElementOfName[el.name] + 1 | |||||
: 0 | |||||
); | |||||
setFieldValue( | |||||
el, | |||||
objectValues[el.name], | |||||
nthElementOfName[el.name], | |||||
elementsWithSameName[el.name], | |||||
); | |||||
}); | |||||
}; | |||||
/** | |||||
* Builds a map of field names with elements that may contain duplicates. | |||||
* @param fieldElementEntries - Entries of field names and their corresponding elements. | |||||
* @returns The map of field names to elements or array of elements if they have duplicates. | |||||
*/ | |||||
const getElementsOfSameName = (fieldElementEntries: [string, HTMLElementWithName][]) => ( | |||||
fieldElementEntries.reduce( | |||||
(currentCount, [, el]) => { | |||||
if (el.tagName === TAG_NAME_INPUT && el.type === INPUT_TYPE_RADIO) { | |||||
return { | |||||
...currentCount, | |||||
[el.name]: [el], | |||||
}; | |||||
} | |||||
return { | |||||
...currentCount, | |||||
[el.name]: ( | |||||
Array.isArray(currentCount[el.name]) | |||||
? [...currentCount[el.name], el] | |||||
: [el] | |||||
), | |||||
}; | |||||
}, | |||||
{} as Record<string, HTMLElement[]>, | |||||
) | |||||
); | |||||
/** | /** | ||||
* Sets the values of all the fields within the form through accessing the DOM nodes. Partial values | * Sets the values of all the fields within the form through accessing the DOM nodes. Partial values | ||||
* may be passed to set values only to certain form fields. | * may be passed to set values only to certain form fields. | ||||
@@ -1212,60 +1247,49 @@ export const setFormValues = ( | |||||
values: unknown, | values: unknown, | ||||
) => { | ) => { | ||||
assertIsFormElement(form, 'getFormValues'); | assertIsFormElement(form, 'getFormValues'); | ||||
const valuesType = typeof values; | const valuesType = typeof values; | ||||
if (!['string', 'object'].includes(valuesType)) { | if (!['string', 'object'].includes(valuesType)) { | ||||
throw new TypeError(`Invalid values argument provided for setFormValues(). Expected "object" or "string", got ${valuesType}`); | throw new TypeError(`Invalid values argument provided for setFormValues(). Expected "object" or "string", got ${valuesType}`); | ||||
} | } | ||||
if (!values) { | if (!values) { | ||||
// reject `null` | |||||
return; | return; | ||||
} | } | ||||
const fieldElements = filterFieldElements(form); | |||||
const objectValues = normalizeValues(values); | const objectValues = normalizeValues(values); | ||||
const fieldElements = filterFieldElements(form); | |||||
const filteredFieldElements = fieldElements.filter(([, el]) => el.name in objectValues); | |||||
const elementsWithSameName = getElementsOfSameName(filteredFieldElements); | |||||
doSetFormValues(filteredFieldElements, elementsWithSameName, objectValues); | |||||
}; | |||||
const elementsWithSameName = fieldElements | |||||
.filter(([, el]) => el.name in objectValues) | |||||
.reduce( | |||||
(currentCount, [, el]) => { | |||||
if (el.tagName === TAG_NAME_INPUT && el.type === INPUT_TYPE_RADIO) { | |||||
return { | |||||
...currentCount, | |||||
[el.name]: [el], | |||||
}; | |||||
} | |||||
return { | |||||
...currentCount, | |||||
[el.name]: ( | |||||
Array.isArray(currentCount[el.name]) | |||||
? [...currentCount[el.name], el] | |||||
: [el] | |||||
), | |||||
}; | |||||
}, | |||||
{} as Record<string, HTMLElement[]>, | |||||
); | |||||
const nthElementOfName = {} as Record<string, number>; | |||||
fieldElements | |||||
.filter(([, el]) => el.name in objectValues) | |||||
.forEach(([, el]) => { | |||||
nthElementOfName[el.name] = ( | |||||
typeof nthElementOfName[el.name] === 'number' | |||||
? nthElementOfName[el.name] + 1 | |||||
: 0 | |||||
); | |||||
setFieldValue( | |||||
el, | |||||
objectValues[el.name], | |||||
nthElementOfName[el.name], | |||||
elementsWithSameName[el.name], | |||||
); | |||||
}); | |||||
/** | |||||
* Clears the values of all the fields within the form through accessing the DOM nodes. Partial | |||||
* values may be passed to set values only to certain form fields. | |||||
* | |||||
* **Note:** This does not reset the inputs' values, instead only unsets them. | |||||
* | |||||
* @param form - The form. | |||||
* @param fieldNames - The field names to clear their corresponding element(s). | |||||
*/ | |||||
export const clearFormValues = ( | |||||
form: HTMLFormElement, | |||||
fieldNames: string | string[], | |||||
) => { | |||||
assertIsFormElement(form, 'clearFormValues'); | |||||
const fieldNamesNormalized = Array.isArray(fieldNames) ? fieldNames : [fieldNames]; | |||||
const fieldElements = filterFieldElements(form); | |||||
const filteredFieldElements = fieldElements.filter( | |||||
([, el]) => fieldNamesNormalized.includes(el.name), | |||||
); | |||||
const elementsWithSameName = getElementsOfSameName(filteredFieldElements); | |||||
const objectValues = Object.fromEntries( | |||||
Object.entries(elementsWithSameName).map(([key]) => [ | |||||
key, '', | |||||
]), | |||||
); | |||||
doSetFormValues(filteredFieldElements, elementsWithSameName, objectValues); | |||||
}; | }; | ||||
/** | /** | ||||
@@ -1276,7 +1300,7 @@ export const setFormValues = ( | |||||
* @see getFormValues | * @see getFormValues | ||||
*/ | */ | ||||
export default (...args: Parameters<typeof getFormValues>) => { | export default (...args: Parameters<typeof getFormValues>) => { | ||||
// eslint-disable-next-line no-console | |||||
console.warn('Default import is deprecated. Use named export `getFormValues()` instead. This default export is only for backwards compatibility.'); | |||||
const logger = typeof console !== 'undefined' ? console : undefined; | |||||
logger?.warn?.('Default import is deprecated. Use named export `getFormValues()` instead. This default export is only for backwards compatibility.'); | |||||
return getFormValues(...args); | return getFormValues(...args); | ||||
}; | }; |