@@ -1014,6 +1014,16 @@ function constructPricing({
10141014}
10151015
10161016describe ( "getReservationUnitPrice" , ( ) => {
1017+ beforeAll ( ( ) => {
1018+ jest . useFakeTimers ( {
1019+ doNotFake : [ "performance" ] ,
1020+ now : new Date ( 2024 , 0 , 1 , 10 , 0 , 0 ) ,
1021+ } ) ;
1022+ } ) ;
1023+ afterAll ( ( ) => {
1024+ jest . useRealTimers ( ) ;
1025+ } ) ;
1026+
10171027 function connstructInput ( {
10181028 date,
10191029 } : {
@@ -1061,7 +1071,51 @@ describe("getReservationUnitPrice", () => {
10611071 expect ( getReservationUnitPrice ( input2 ) ) . toEqual ( "10,00 - 20,00 € / tunti" ) ;
10621072 } ) ;
10631073
1064- test . todo ( "Tax change should work" ) ;
1074+ test ( "future change in tax uses active price" , ( ) => {
1075+ const date = addDays ( new Date ( ) , 15 ) ;
1076+ const input = {
1077+ pricingDate : date ,
1078+ reservationUnit : {
1079+ pricings : [
1080+ constructPricing ( {
1081+ begins : addDays ( new Date ( ) , - 10 ) ,
1082+ highestPrice : 20 ,
1083+ taxPercentage : 24 ,
1084+ status : Status . Active ,
1085+ } ) ,
1086+ constructPricing ( {
1087+ begins : addDays ( new Date ( ) , 10 ) ,
1088+ highestPrice : 25 ,
1089+ taxPercentage : 25.5 ,
1090+ status : Status . Future ,
1091+ } ) ,
1092+ ] ,
1093+ } ,
1094+ } ;
1095+ expect ( getReservationUnitPrice ( input ) ) . toBe ( "20,00 € / tunti" ) ;
1096+ } ) ;
1097+ test ( "future change in tax for free uses future price" , ( ) => {
1098+ const date = addDays ( new Date ( ) , 15 ) ;
1099+ const input = {
1100+ pricingDate : date ,
1101+ reservationUnit : {
1102+ pricings : [
1103+ constructPricing ( {
1104+ begins : addDays ( new Date ( ) , - 10 ) ,
1105+ status : Status . Active ,
1106+ pricingType : PricingType . Free ,
1107+ } ) ,
1108+ constructPricing ( {
1109+ begins : addDays ( new Date ( ) , 10 ) ,
1110+ highestPrice : 25 ,
1111+ taxPercentage : 25.5 ,
1112+ status : Status . Future ,
1113+ } ) ,
1114+ ] ,
1115+ } ,
1116+ } ;
1117+ expect ( getReservationUnitPrice ( input ) ) . toBe ( "25,00 € / tunti" ) ;
1118+ } ) ;
10651119} ) ;
10661120
10671121describe ( "isReservationUnitPaidInFuture" , ( ) => {
0 commit comments