66 multiRuleSchema ,
77 schemaSelfContainedValueForMaximumMinimumValues ,
88 schemaSelfContainedValueForTitleWithNoTemplate ,
9- schemaWhereValidationAndComputedValueIsAppliedOnNormalThenStatement ,
109 schemaWithChecksAndThenValidationsOnThen ,
1110 schemaWithComputedAttributeThatDoesntExist ,
1211 schemaWithComputedAttributeThatDoesntExistDescription ,
@@ -17,21 +16,18 @@ import {
1716 schemaWithDeepVarThatDoesNotExist ,
1817 schemaWithDeepVarThatDoesNotExistOnFieldset ,
1918 schemaWithGreaterThanChecksForThreeFields ,
20- schemaWithIfStatementWithComputedValuesAndValidationChecks ,
2119 schemaWithInlineMultipleRulesForComputedAttributes ,
2220 schemaWithInlineRuleForComputedAttributeWithCopy ,
2321 schemaWithInlinedRuleOnComputedAttributeThatReferencesUnknownVar ,
2422 schemaWithJSFLogicAndInlineRule ,
2523 schemaWithMissingComputedValue ,
2624 schemaWithMissingRule ,
2725 schemaWithMissingValueInlineRule ,
28- schemaWithMultipleComputedValueChecks ,
2926 schemaWithNativeAndJSONLogicChecks ,
3027 schemaWithNonRequiredField ,
3128 schemaWithPropertiesCheckAndValidationsInAIf ,
3229 schemaWithPropertyThatDoesNotExistInThatLevelButDoesInFieldset ,
3330 schemaWithTwoRules ,
34- schemaWithTwoValidationsWhereOneOfThemIsAppliedConditionally ,
3531 schemaWithValidationThatDoesNotExistOnProperty ,
3632 schemaWithVarThatDoesNotExist ,
3733} from './jsonLogicFixtures' ;
@@ -396,72 +392,6 @@ describe('cross-value validations', () => {
396392 undefined
397393 ) ;
398394 } ) ;
399-
400- it ( 'Handle multiple computedValue checks by ANDing them together' , ( ) => {
401- const { handleValidation } = createHeadlessForm ( schemaWithMultipleComputedValueChecks , {
402- strictInputType : false ,
403- } ) ;
404- expect ( handleValidation ( { } ) . formErrors ) . toEqual ( {
405- field_a : 'Required field' ,
406- field_b : 'Required field' ,
407- } ) ;
408- expect ( handleValidation ( { field_a : 10 , field_b : 8 } ) . formErrors ) . toEqual ( {
409- field_c : 'Required field' ,
410- } ) ;
411- expect ( handleValidation ( { field_a : 10 , field_b : 8 , field_c : 0 } ) . formErrors ) . toEqual ( {
412- field_c : 'Must be two times B' ,
413- } ) ;
414- expect ( handleValidation ( { field_a : 10 , field_b : 8 , field_c : 17 } ) . formErrors ) . toEqual (
415- undefined
416- ) ;
417- } ) ;
418-
419- it ( 'Handle having a true condition with both validations and computedValue checks' , ( ) => {
420- const { handleValidation } = createHeadlessForm (
421- schemaWithIfStatementWithComputedValuesAndValidationChecks ,
422- { strictInputType : false }
423- ) ;
424- expect ( handleValidation ( { field_a : 1 , field_b : 1 } ) . formErrors ) . toEqual ( undefined ) ;
425- expect ( handleValidation ( { field_a : 10 , field_b : 20 } ) . formErrors ) . toEqual ( undefined ) ;
426- expect ( handleValidation ( { field_a : 10 , field_b : 9 } ) . formErrors ) . toEqual ( {
427- field_c : 'Required field' ,
428- } ) ;
429- expect ( handleValidation ( { field_a : 10 , field_b : 9 , field_c : 10 } ) . formErrors ) . toEqual (
430- undefined
431- ) ;
432- } ) ;
433-
434- it ( 'Apply validations and computed values on normal if statement.' , ( ) => {
435- const { fields, handleValidation } = createHeadlessForm (
436- schemaWhereValidationAndComputedValueIsAppliedOnNormalThenStatement ,
437- { strictInputType : false }
438- ) ;
439- expect ( handleValidation ( { field_a : 0 , field_b : 0 } ) . formErrors ) . toEqual ( undefined ) ;
440- expect ( handleValidation ( { field_a : 20 , field_b : 0 } ) . formErrors ) . toEqual ( {
441- field_b : 'Must be greater than Field A + 10' ,
442- } ) ;
443- const [ , fieldB ] = fields ;
444- expect ( fieldB . label ) . toEqual ( 'Must be greater than 30.' ) ;
445- expect ( handleValidation ( { field_a : 20 , field_b : 31 } ) . formErrors ) . toEqual ( undefined ) ;
446- } ) ;
447-
448- it ( 'When we have a required validation on a top level property and another validation is added, both should be accounted for.' , ( ) => {
449- const { handleValidation } = createHeadlessForm (
450- schemaWithTwoValidationsWhereOneOfThemIsAppliedConditionally ,
451- { strictInputType : false }
452- ) ;
453- expect ( handleValidation ( { field_a : 10 , field_b : 0 } ) . formErrors ) . toEqual ( {
454- field_b : 'Must be greater than A' ,
455- } ) ;
456- expect ( handleValidation ( { field_a : 10 , field_b : 20 } ) . formErrors ) . toEqual ( undefined ) ;
457- expect ( handleValidation ( { field_a : 20 , field_b : 10 } ) . formErrors ) . toEqual ( {
458- field_b : 'Must be greater than A' ,
459- } ) ;
460- expect ( handleValidation ( { field_a : 20 , field_b : 21 } ) . formErrors ) . toEqual ( {
461- field_b : 'Must be greater than two times A' ,
462- } ) ;
463- expect ( handleValidation ( { field_a : 20 , field_b : 41 } ) . formErrors ) . toEqual ( ) ;
464- } ) ;
465395 } ) ;
466396
467397 describe ( 'Multiple validations' , ( ) => {
0 commit comments