diff --git a/src/tests/createHeadlessForm.test.js b/src/tests/createHeadlessForm.test.js index b2b55681..597c9faf 100644 --- a/src/tests/createHeadlessForm.test.js +++ b/src/tests/createHeadlessForm.test.js @@ -422,7 +422,7 @@ describe('createHeadlessForm', () => { }); describe('field support', () => { - function assertOptionsValidation({ handleValidation, fieldName, validOptions }) { + function assertOptionsAllowed({ handleValidation, fieldName, validOptions }) { const validateForm = (vals) => friendlyError(handleValidation(vals)); // All allowed options are valid @@ -448,7 +448,7 @@ describe('createHeadlessForm', () => { [fieldName]: 'Required field', }); - // As required field, empty string ("") is also considered empty. @BUG XXX-000 + // As required field, empty string ("") is also considered empty. @BUG RMT-518 expect( validateForm({ [fieldName]: '', @@ -586,7 +586,7 @@ describe('createHeadlessForm', () => { }, ]); - assertOptionsValidation({ + assertOptionsAllowed({ handleValidation, fieldName: 'benefits', validOptions: ['Medical Insurance', 'Health Insurance', 'Travel Bonus'], @@ -620,7 +620,7 @@ describe('createHeadlessForm', () => { expect(fieldSelect).not.toHaveProperty('multiple'); - assertOptionsValidation({ + assertOptionsAllowed({ handleValidation, fieldName: 'browsers', validOptions: ['chr', 'ff', 'ie'], @@ -738,7 +738,7 @@ describe('createHeadlessForm', () => { }, ]); - assertOptionsValidation({ + assertOptionsAllowed({ handleValidation, fieldName: 'has_siblings', validOptions: ['yes', 'no'], @@ -768,7 +768,7 @@ describe('createHeadlessForm', () => { }, ]); - assertOptionsValidation({ + assertOptionsAllowed({ handleValidation, fieldName: 'has_siblings', validOptions: ['yes', 'no'], @@ -814,7 +814,7 @@ describe('createHeadlessForm', () => { }); }); - describe('support "radio" optional field - more examples @BUG XXX-000', () => { + describe('support "radio" optional field - more examples @BUG RMT-518', () => { function assertCommonBehavior(validateForm) { // Happy path expect(validateForm({ has_car: 'yes' })).toBeUndefined(); @@ -823,8 +823,8 @@ describe('createHeadlessForm', () => { expect(validateForm({})).toBeUndefined(); // Does not accept other values - expect(validateForm({ has_car: 'jdsadjag' })).toEqual({ - has_car: 'The option "jdsadjag" is not valid.', + expect(validateForm({ has_car: 'blah-blah' })).toEqual({ + has_car: 'The option "blah-blah" is not valid.', }); // Does not accept "null" as string @@ -832,7 +832,7 @@ describe('createHeadlessForm', () => { has_car: 'The option "null" is not valid.', }); - // Accepts empty string ("") — @BUG XXX-000 + // Accepts empty string ("") — @BUG RMT-518 // Expectation: Does not accept empty string ("") expect(validateForm({ has_car: '' })).toBeUndefined(); } diff --git a/src/yupSchema.js b/src/yupSchema.js index 5b37acca..ee1d488c 100644 --- a/src/yupSchema.js +++ b/src/yupSchema.js @@ -102,9 +102,9 @@ const getOptionsAllowed = (field) => { return optionsBroken; /* - [1] @BUG XXX-000 - explanation + [1] @BUG RMT-518 - explanation The "" (empty string) is to keep retrocompatibily with previous version. - The "" does NOT match the JSON Schema specs, as `oneOf` keyword does not allow "" value, ever. + The "" does NOT match the JSON Schema specs. In the specs the `oneOf` keyword does not allow "" value by default. Preving its value in this PR#18 would be a major BREAKING CHANGE because before any string was allowed but now only the options[].value are,