@@ -942,3 +942,100 @@ describe("bugfix test for left and width calculation", () => {
942942 expect ( leftAndWidth . width ) . toBe ( 1 )
943943 } )
944944} )
945+
946+ describe ( "bugfix test for left and width calculation when item starts after end of day time" , ( ) => {
947+ it ( "should calculate left and width correctly for weeks view" , ( ) => {
948+ const item : TimeSlotBooking = {
949+ key : "1" ,
950+ title : "Test" ,
951+ startDate : dayjs ( )
952+ . startOf ( "week" )
953+ . add ( 1 , "days" )
954+ . subtract ( 1 , "minute" ) ,
955+ endDate : dayjs ( ) . startOf ( "week" ) . add ( 2 , "days" ) ,
956+ }
957+
958+ const timeSteps = 60
959+
960+ const props = calculateTimeSlotPropertiesForView (
961+ dayjs ( ) . startOf ( "week" ) . add ( 6 , "hours" ) ,
962+ dayjs ( ) . startOf ( "week" ) . add ( 1 , "week" ) . add ( 22 , "hours" ) ,
963+ timeSteps ,
964+ "days" ,
965+ false ,
966+ )
967+
968+ // get slots
969+ const result = getStartAndEndSlot (
970+ item ,
971+ props . slotsArray ,
972+ props . timeFrameDay ,
973+ props . viewType ,
974+ )
975+
976+ expect ( result . status ) . toBe ( "in" )
977+ expect ( result . startSlot ) . toBe ( 1 ) // should be 1 because past 22:00 when the time frame of day ends
978+ expect ( result . endSlot ) . toBe ( 2 )
979+
980+ // calculate left and width
981+ const leftAndWidth = getLeftAndWidth (
982+ item ,
983+ result . startSlot ,
984+ result . endSlot ,
985+ props . slotsArray ,
986+ props . timeFrameDay ,
987+ props . viewType ,
988+ timeSteps ,
989+ )
990+
991+ expect ( leftAndWidth . left ) . toBe ( 0 )
992+ expect ( leftAndWidth . width ) . toBe ( 1 )
993+ } )
994+ } )
995+
996+ describe ( "bugfix test for left and width calculation when item starts before start of day time" , ( ) => {
997+ it ( "should calculate left and width correctly for weeks view" , ( ) => {
998+ const item : TimeSlotBooking = {
999+ key : "1" ,
1000+ title : "Test" ,
1001+ startDate : dayjs ( ) . startOf ( "week" ) . add ( 1 , "days" ) . add ( 1 , "hour" ) ,
1002+ endDate : dayjs ( ) . startOf ( "week" ) . add ( 2 , "days" ) ,
1003+ }
1004+
1005+ const timeSteps = 60
1006+
1007+ const props = calculateTimeSlotPropertiesForView (
1008+ dayjs ( ) . startOf ( "week" ) . add ( 6 , "hours" ) ,
1009+ dayjs ( ) . startOf ( "week" ) . add ( 1 , "week" ) . add ( 22 , "hours" ) ,
1010+ timeSteps ,
1011+ "days" ,
1012+ false ,
1013+ )
1014+
1015+ // get slots
1016+ const result = getStartAndEndSlot (
1017+ item ,
1018+ props . slotsArray ,
1019+ props . timeFrameDay ,
1020+ props . viewType ,
1021+ )
1022+
1023+ expect ( result . status ) . toBe ( "in" )
1024+ expect ( result . startSlot ) . toBe ( 1 ) // should be 1 because past 22:00 when the time frame of day ends
1025+ expect ( result . endSlot ) . toBe ( 2 )
1026+
1027+ // calculate left and width
1028+ const leftAndWidth = getLeftAndWidth (
1029+ item ,
1030+ result . startSlot ,
1031+ result . endSlot ,
1032+ props . slotsArray ,
1033+ props . timeFrameDay ,
1034+ props . viewType ,
1035+ timeSteps ,
1036+ )
1037+
1038+ expect ( leftAndWidth . left ) . toBe ( 0 )
1039+ expect ( leftAndWidth . width ) . toBe ( 1 )
1040+ } )
1041+ } )
0 commit comments