@@ -21,6 +21,20 @@ describe('repairConfig', () => {
2121 ] ,
2222 } ) ,
2323 }
24+ const multiPeriodCamp = {
25+ _meta : { self : '/camps/1a2b3c4d' } ,
26+ shortTitle : 'test camp' ,
27+ periods : ( ) => ( {
28+ items : [
29+ {
30+ _meta : { self : '/periods/1a2b3c4d' } ,
31+ } ,
32+ {
33+ _meta : { self : '/periods/11223344' } ,
34+ } ,
35+ ] ,
36+ } ) ,
37+ }
2438 const availableLocales = [ 'en-GB' , 'de-CH' , 'de-CH-scout' ]
2539 const componentRepairers = Object . fromEntries (
2640 [
@@ -38,6 +52,13 @@ describe('repairConfig', () => {
3852 { type : 'Picasso' , options : { periods : [ '/periods/1a2b3c4d' ] , orientation : 'L' } } ,
3953 ]
4054 const args = [ camp , availableLocales , 'en' , componentRepairers , defaultContents ]
55+ const multiPeriodArgs = [
56+ multiPeriodCamp ,
57+ availableLocales ,
58+ 'en' ,
59+ componentRepairers ,
60+ defaultContents ,
61+ ]
4162
4263 test ( 'fills empty config with default data' , async ( ) => {
4364 // given
@@ -479,7 +500,10 @@ describe('repairConfig', () => {
479500 contents : [
480501 {
481502 type : 'Picasso' ,
482- options : { periods : [ ] , orientation : 'L' } ,
503+ options : {
504+ periods : [ '/periods/1a2b3c4d' ] ,
505+ orientation : 'L' ,
506+ } ,
483507 } ,
484508 ] ,
485509 documentName : 'test camp' ,
@@ -564,7 +588,7 @@ describe('repairConfig', () => {
564588 }
565589
566590 // when
567- const result = repairConfig ( config , ...args )
591+ const result = repairConfig ( config , ...multiPeriodArgs )
568592
569593 // then
570594 expect ( result ) . toEqual ( {
@@ -580,6 +604,40 @@ describe('repairConfig', () => {
580604 } )
581605 } )
582606
607+ test ( 'does not allow empty periods if there is only one period in the camp' , async ( ) => {
608+ // given
609+ const config = {
610+ camp : '/camps/1a2b3c4d' ,
611+ contents : [
612+ {
613+ type : 'Picasso' ,
614+ options : { periods : [ ] , orientation : 'L' } ,
615+ } ,
616+ ] ,
617+ documentName : 'test camp' ,
618+ language : 'en-GB' ,
619+ }
620+
621+ // when
622+ const result = repairConfig ( config , ...args )
623+
624+ // then
625+ expect ( result ) . toEqual ( {
626+ camp : '/camps/1a2b3c4d' ,
627+ contents : [
628+ {
629+ type : 'Picasso' ,
630+ options : {
631+ periods : [ '/periods/1a2b3c4d' ] ,
632+ orientation : 'L' ,
633+ } ,
634+ } ,
635+ ] ,
636+ documentName : 'test camp' ,
637+ language : 'en-GB' ,
638+ } )
639+ } )
640+
583641 test ( 'overwrites invalid orientation' , async ( ) => {
584642 // given
585643 const config = {
@@ -670,7 +728,7 @@ describe('repairConfig', () => {
670728 {
671729 type : 'Program' ,
672730 options : {
673- periods : [ ] ,
731+ periods : [ '/periods/1a2b3c4d' ] ,
674732 dayOverview : true ,
675733 } ,
676734 } ,
@@ -768,7 +826,7 @@ describe('repairConfig', () => {
768826 }
769827
770828 // when
771- const result = repairConfig ( config , ...args )
829+ const result = repairConfig ( config , ...multiPeriodArgs )
772830
773831 // then
774832 expect ( result ) . toEqual ( {
@@ -784,6 +842,43 @@ describe('repairConfig', () => {
784842 } )
785843 } )
786844
845+ test ( 'does not allow empty periods if there is only one period in the camp' , async ( ) => {
846+ // given
847+ const config = {
848+ camp : '/camps/1a2b3c4d' ,
849+ contents : [
850+ {
851+ type : 'Program' ,
852+ options : {
853+ periods : [ '/periods/1a2b3c4d' ] ,
854+ dayOverview : true ,
855+ } ,
856+ } ,
857+ ] ,
858+ documentName : 'test camp' ,
859+ language : 'en-GB' ,
860+ }
861+
862+ // when
863+ const result = repairConfig ( config , ...args )
864+
865+ // then
866+ expect ( result ) . toEqual ( {
867+ camp : '/camps/1a2b3c4d' ,
868+ contents : [
869+ {
870+ type : 'Program' ,
871+ options : {
872+ periods : [ '/periods/1a2b3c4d' ] ,
873+ dayOverview : true ,
874+ } ,
875+ } ,
876+ ] ,
877+ documentName : 'test camp' ,
878+ language : 'en-GB' ,
879+ } )
880+ } )
881+
787882 test ( 'filters out unknown periods' , async ( ) => {
788883 // given
789884 const config = {
@@ -845,7 +940,10 @@ describe('repairConfig', () => {
845940 contents : [
846941 {
847942 type : 'Story' ,
848- options : { periods : [ ] , contentType : 'Storycontext' } ,
943+ options : {
944+ periods : [ '/periods/1a2b3c4d' ] ,
945+ contentType : 'Storycontext' ,
946+ } ,
849947 } ,
850948 ] ,
851949 documentName : 'test camp' ,
@@ -868,7 +966,7 @@ describe('repairConfig', () => {
868966 }
869967
870968 // when
871- const result = repairConfig ( config , ...args )
969+ const result = repairConfig ( config , ...multiPeriodArgs )
872970
873971 // then
874972 expect ( result ) . toEqual ( {
@@ -884,6 +982,43 @@ describe('repairConfig', () => {
884982 } )
885983 } )
886984
985+ test ( 'does not allow empty periods if there is only one period in the camp' , async ( ) => {
986+ // given
987+ const config = {
988+ camp : '/camps/1a2b3c4d' ,
989+ contents : [
990+ {
991+ type : 'Story' ,
992+ options : {
993+ periods : [ '/periods/1a2b3c4d' ] ,
994+ contentType : 'Storycontext' ,
995+ } ,
996+ } ,
997+ ] ,
998+ documentName : 'test camp' ,
999+ language : 'en-GB' ,
1000+ }
1001+
1002+ // when
1003+ const result = repairConfig ( config , ...args )
1004+
1005+ // then
1006+ expect ( result ) . toEqual ( {
1007+ camp : '/camps/1a2b3c4d' ,
1008+ contents : [
1009+ {
1010+ type : 'Story' ,
1011+ options : {
1012+ periods : [ '/periods/1a2b3c4d' ] ,
1013+ contentType : 'Storycontext' ,
1014+ } ,
1015+ } ,
1016+ ] ,
1017+ documentName : 'test camp' ,
1018+ language : 'en-GB' ,
1019+ } )
1020+ } )
1021+
8871022 test ( 'filters out unknown periods' , async ( ) => {
8881023 // given
8891024 const config = {
@@ -982,7 +1117,10 @@ describe('repairConfig', () => {
9821117 contents : [
9831118 {
9841119 type : 'SafetyConsiderations' ,
985- options : { periods : [ ] , contentType : 'SafetyConsiderations' } ,
1120+ options : {
1121+ periods : [ '/periods/1a2b3c4d' ] ,
1122+ contentType : 'SafetyConsiderations' ,
1123+ } ,
9861124 } ,
9871125 ] ,
9881126 documentName : 'test camp' ,
@@ -1005,7 +1143,7 @@ describe('repairConfig', () => {
10051143 }
10061144
10071145 // when
1008- const result = repairConfig ( config , ...args )
1146+ const result = repairConfig ( config , ...multiPeriodArgs )
10091147
10101148 // then
10111149 expect ( result ) . toEqual ( {
@@ -1021,6 +1159,40 @@ describe('repairConfig', () => {
10211159 } )
10221160 } )
10231161
1162+ test ( 'does not allow empty period when there is only one period in the camp' , async ( ) => {
1163+ // given
1164+ const config = {
1165+ camp : '/camps/1a2b3c4d' ,
1166+ contents : [
1167+ {
1168+ type : 'SafetyConsiderations' ,
1169+ options : { periods : [ ] , contentType : 'SafetyConsiderations' } ,
1170+ } ,
1171+ ] ,
1172+ documentName : 'test camp' ,
1173+ language : 'en-GB' ,
1174+ }
1175+
1176+ // when
1177+ const result = repairConfig ( config , ...args )
1178+
1179+ // then
1180+ expect ( result ) . toEqual ( {
1181+ camp : '/camps/1a2b3c4d' ,
1182+ contents : [
1183+ {
1184+ type : 'SafetyConsiderations' ,
1185+ options : {
1186+ periods : [ '/periods/1a2b3c4d' ] ,
1187+ contentType : 'SafetyConsiderations' ,
1188+ } ,
1189+ } ,
1190+ ] ,
1191+ documentName : 'test camp' ,
1192+ language : 'en-GB' ,
1193+ } )
1194+ } )
1195+
10241196 test ( 'filters out unknown periods' , async ( ) => {
10251197 // given
10261198 const config = {
@@ -1152,7 +1324,9 @@ describe('repairConfig', () => {
11521324 contents : [
11531325 {
11541326 type : 'ActivityList' ,
1155- options : { periods : [ ] } ,
1327+ options : {
1328+ periods : [ '/periods/1a2b3c4d' ] ,
1329+ } ,
11561330 } ,
11571331 ] ,
11581332 documentName : 'test camp' ,
@@ -1175,7 +1349,7 @@ describe('repairConfig', () => {
11751349 }
11761350
11771351 // when
1178- const result = repairConfig ( config , ...args )
1352+ const result = repairConfig ( config , ...multiPeriodArgs )
11791353
11801354 // then
11811355 expect ( result ) . toEqual ( {
@@ -1191,6 +1365,39 @@ describe('repairConfig', () => {
11911365 } )
11921366 } )
11931367
1368+ test ( 'does not allow empty period if there is only one period in the camp' , async ( ) => {
1369+ // given
1370+ const config = {
1371+ camp : '/camps/1a2b3c4d' ,
1372+ contents : [
1373+ {
1374+ type : 'ActivityList' ,
1375+ options : { periods : [ ] } ,
1376+ } ,
1377+ ] ,
1378+ documentName : 'test camp' ,
1379+ language : 'en-GB' ,
1380+ }
1381+
1382+ // when
1383+ const result = repairConfig ( config , ...args )
1384+
1385+ // then
1386+ expect ( result ) . toEqual ( {
1387+ camp : '/camps/1a2b3c4d' ,
1388+ contents : [
1389+ {
1390+ type : 'ActivityList' ,
1391+ options : {
1392+ periods : [ '/periods/1a2b3c4d' ] ,
1393+ } ,
1394+ } ,
1395+ ] ,
1396+ documentName : 'test camp' ,
1397+ language : 'en-GB' ,
1398+ } )
1399+ } )
1400+
11941401 test ( 'filters out unknown periods' , async ( ) => {
11951402 // given
11961403 const config = {
0 commit comments