@@ -202,6 +202,7 @@ const reservation: ReservationNode = {
202202 price : "0" ,
203203 bufferTimeBefore : 0 ,
204204 bufferTimeAfter : 0 ,
205+ paymentOrder : [ ] ,
205206 begin : addHours ( startOfToday ( ) , 34 ) . toISOString ( ) ,
206207 end : addHours ( startOfToday ( ) , 35 ) . toISOString ( ) ,
207208 reservationUnit : [ reservationUnit ] ,
@@ -559,7 +560,12 @@ describe("canReservationBeChanged", () => {
559560 } ) ;
560561
561562 test ( "returns true with default data" , ( ) => {
562- expect ( canReservationTimeBeChanged ( { reservation } ) ) . toStrictEqual ( [ true ] ) ;
563+ expect (
564+ canReservationTimeBeChanged ( {
565+ reservation,
566+ reservationUnit,
567+ } )
568+ ) . toStrictEqual ( [ true ] ) ;
563569 } ) ;
564570
565571 test ( "returns false with non-confirmed reservation" , ( ) => {
@@ -569,6 +575,7 @@ describe("canReservationBeChanged", () => {
569575 ...reservation ,
570576 state : State . Created ,
571577 } ,
578+ reservationUnit,
572579 } )
573580 ) . toStrictEqual ( [ false , "RESERVATION_MODIFICATION_NOT_ALLOWED" ] ) ;
574581 } ) ;
@@ -580,76 +587,81 @@ describe("canReservationBeChanged", () => {
580587 ...reservation ,
581588 begin : addHours ( new Date ( ) , - 1 ) . toISOString ( ) ,
582589 } ,
590+ reservationUnit,
583591 } as CanReservationBeChangedProps )
584592 ) . toStrictEqual ( [ false , "RESERVATION_BEGIN_IN_PAST" ] ) ;
585593 } ) ;
586594
587595 test ( "handles cancellation rule check" , ( ) => {
596+ const reservationUnit1 : ReservationUnitNode = {
597+ ...reservationUnit ,
598+ cancellationRule : null ,
599+ } ;
588600 expect (
589601 canReservationTimeBeChanged ( {
590602 reservation : {
591603 ...reservation ,
592- reservationUnit : [
593- {
594- ...reservationUnit ,
595- cancellationRule : null ,
596- } ,
597- ] ,
604+ reservationUnit : [ reservationUnit1 ] ,
598605 } ,
606+ reservationUnit : reservationUnit1 ,
599607 } as CanReservationBeChangedProps )
600608 ) . toStrictEqual ( [ false , "RESERVATION_MODIFICATION_NOT_ALLOWED" ] ) ;
601609
610+ const reservationUnit2 : ReservationUnitNode = {
611+ ...reservationUnit ,
612+ cancellationRule : {
613+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
614+ ...reservationUnit . cancellationRule ! ,
615+ needsHandling : true ,
616+ } ,
617+ } ;
602618 expect (
603619 canReservationTimeBeChanged ( {
604620 reservation : {
605621 ...reservation ,
606- reservationUnit : [
607- {
608- ...reservationUnit ,
609- cancellationRule : {
610- needsHandling : true ,
611- } ,
612- } ,
613- ] ,
622+ reservationUnit : [ reservationUnit2 ] ,
614623 } ,
624+ reservationUnit : reservationUnit2 ,
615625 } as CanReservationBeChangedProps )
616626 ) . toStrictEqual ( [ false , "RESERVATION_MODIFICATION_NOT_ALLOWED" ] ) ;
617627 } ) ;
618628
619629 test ( "handles cancellation rule buffer check" , ( ) => {
630+ const reservationUnit1 : ReservationUnitNode = {
631+ ...reservationUnit ,
632+ cancellationRule : {
633+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
634+ ...reservationUnit . cancellationRule ! ,
635+ canBeCancelledTimeBefore : 3000 ,
636+ } ,
637+ } ;
620638 expect (
621639 canReservationTimeBeChanged ( {
622640 reservation : {
623641 ...reservation ,
624642 begin : addHours ( new Date ( ) , 1 ) . toISOString ( ) ,
625- reservationUnit : [
626- {
627- ...reservationUnit ,
628- cancellationRule : {
629- ...reservationUnit . cancellationRule ,
630- canBeCancelledTimeBefore : 3000 ,
631- } ,
632- } ,
633- ] ,
643+ reservationUnit : [ reservationUnit1 ] ,
634644 } ,
645+ reservationUnit : reservationUnit1 ,
635646 } as CanReservationBeChangedProps )
636647 ) . toStrictEqual ( [ true ] ) ;
637648
649+ const reservationUnit2 : ReservationUnitNode = {
650+ ...reservationUnit ,
651+ cancellationRule : {
652+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
653+ ...reservationUnit . cancellationRule ! ,
654+ canBeCancelledTimeBefore : 3601 ,
655+ } ,
656+ } ;
638657 expect (
639658 canReservationTimeBeChanged ( {
640659 reservation : {
641660 ...reservation ,
642661 begin : addHours ( new Date ( ) , 1 ) . toISOString ( ) ,
643- reservationUnit : [
644- {
645- ...reservationUnit ,
646- cancellationRule : {
647- ...reservationUnit . cancellationRule ,
648- canBeCancelledTimeBefore : 3601 ,
649- } ,
650- } ,
651- ] ,
662+ reservationUnit : [ reservationUnit2 ] ,
652663 } ,
664+ reservationUnit : reservationUnit2 ,
653665 } as CanReservationBeChangedProps )
654666 ) . toStrictEqual ( [ false , "CANCELLATION_TIME_PAST" ] ) ;
655667 } ) ;
@@ -658,6 +670,7 @@ describe("canReservationBeChanged", () => {
658670 expect (
659671 canReservationTimeBeChanged ( {
660672 reservation : { ...reservation , isHandled : true } ,
673+ reservationUnit,
661674 } as CanReservationBeChangedProps )
662675 ) . toStrictEqual ( [ false , "RESERVATION_MODIFICATION_NOT_ALLOWED" ] ) ;
663676 } ) ;
@@ -667,6 +680,7 @@ describe("canReservationBeChanged", () => {
667680 canReservationTimeBeChanged ( {
668681 reservation,
669682 newReservation : { ...reservation , price : "2.02" } ,
683+ reservationUnit,
670684 } as CanReservationBeChangedProps )
671685 ) . toStrictEqual ( [ false , "RESERVATION_MODIFICATION_NOT_ALLOWED" ] ) ;
672686 } ) ;
0 commit comments