@@ -35,7 +35,7 @@ describe("surveyQuestionSchema", () => {
3535 const result = SurveyQuestionSchema . safeParse ( minimalQuestion ) ;
3636 expect ( result . success ) . toBe ( true ) ;
3737 if ( result . success ) {
38- expect ( result . data . required ) . toBe ( true ) ;
38+ expect ( result . data . required ) . toBe ( false ) ;
3939 expect ( result . data . multiple ) . toBe ( false ) ;
4040 }
4141 } ) ;
@@ -248,6 +248,7 @@ describe("surveyFileSchema", () => {
248248 questions : [
249249 {
250250 label : "Test?" ,
251+ required : true ,
251252 choices : [ "Yes" , "No" ]
252253 }
253254 ]
@@ -427,26 +428,30 @@ describe("surveyFileSchema", () => {
427428 expect ( result . success ) . toBe ( true ) ;
428429 } ) ;
429430
430- it ( "accepts file where required is not explicitly set (defaults to true )" , ( ) => {
431+ it ( "accepts file with explicit required:true and omitted required (defaults to false )" , ( ) => {
431432 const validFile = {
432433 title : "Profile" ,
433434 label : "profile" ,
434435 position : 1 ,
435436 questions : [
436437 {
437438 label : "Question 1?" ,
439+ required : true ,
438440 choices : [ "Yes" , "No" ]
439441 } ,
440442 {
441443 label : "Question 2?" ,
442- required : false ,
443444 choices : [ "Yes" , "No" ]
444445 }
445446 ]
446447 } ;
447448
448449 const result = SurveyFileSchema . safeParse ( validFile ) ;
449450 expect ( result . success ) . toBe ( true ) ;
451+ if ( result . success ) {
452+ expect ( result . data . questions [ 0 ] . required ) . toBe ( true ) ;
453+ expect ( result . data . questions [ 1 ] . required ) . toBe ( false ) ;
454+ }
450455 } ) ;
451456} ) ;
452457
@@ -459,6 +464,7 @@ describe("validateSurveyFile helper", () => {
459464 questions : [
460465 {
461466 label : "Test question?" ,
467+ required : true ,
462468 choices : [ "Yes" , "No" ]
463469 }
464470 ]
@@ -509,6 +515,7 @@ describe("validateSurveyFileSafe helper", () => {
509515 questions : [
510516 {
511517 label : "Test question?" ,
518+ required : true ,
512519 choices : [ "Yes" , "No" ]
513520 }
514521 ]
@@ -788,6 +795,7 @@ describe("edge case tests", () => {
788795 questions : [
789796 {
790797 label : "What is your education level?" ,
798+ required : true ,
791799 choices : [ "Bachelor's" , "Master's" , "PhD" , "Self-taught" ]
792800 }
793801 ]
0 commit comments