@@ -52,4 +52,49 @@ describe('validateRequiredDay', function () {
52
52
expect ( result ) . to . be . instanceOf ( FieldError ) ;
53
53
expect ( result ?. errorKeyOrMessage ) . to . equal ( 'requiredYearField' ) ;
54
54
} ) ;
55
+
56
+ it ( 'Validating a day component that requires month and year will not return a FieldError if year and month are given' , async function ( ) {
57
+ const component = {
58
+ ...simpleDayField ,
59
+ fields : {
60
+ year : { required : true } ,
61
+ month : { required : true } ,
62
+ day : { hide : true }
63
+ } ,
64
+ } ;
65
+ const data = { component : '07/2024' } ;
66
+ const context = generateProcessorContext ( component , data ) ;
67
+ const result = await validateRequiredDay ( context ) ;
68
+ expect ( result ) . to . equal ( null ) ;
69
+ } ) ;
70
+
71
+ it ( 'Validating a day component that requires day and year will not return a FieldError if year and day are given' , async function ( ) {
72
+ const component = {
73
+ ...simpleDayField ,
74
+ fields : {
75
+ year : { required : true } ,
76
+ day : { required : true } ,
77
+ month : { hide : true }
78
+ } ,
79
+ } ;
80
+ const data = { component : '24/2024' } ;
81
+ const context = generateProcessorContext ( component , data ) ;
82
+ const result = await validateRequiredDay ( context ) ;
83
+ expect ( result ) . to . equal ( null ) ;
84
+ } ) ;
85
+
86
+ it ( 'Validating a day component that requires day and month will not return a FieldError if day and month are given' , async function ( ) {
87
+ const component = {
88
+ ...simpleDayField ,
89
+ fields : {
90
+ month : { required : true } ,
91
+ day : { required : true } ,
92
+ year : { hide : true }
93
+ } ,
94
+ } ;
95
+ const data = { component : '07/24' } ;
96
+ const context = generateProcessorContext ( component , data ) ;
97
+ const result = await validateRequiredDay ( context ) ;
98
+ expect ( result ) . to . equal ( null ) ;
99
+ } ) ;
55
100
} ) ;
0 commit comments