@@ -51,6 +51,7 @@ import {
5151 getMidnightDate ,
5252 registerLocale ,
5353 isMonthYearDisabled ,
54+ safeMultipleDatesFormat ,
5455} from "../date_utils" ;
5556
5657registerLocale ( "pt-BR" , ptBR ) ;
@@ -1230,6 +1231,33 @@ describe("date_utils", () => {
12301231 } ) ;
12311232 } ) ;
12321233
1234+ describe ( "safeMultipleDatesFormat" , ( ) => {
1235+ const props = {
1236+ dateFormat : "MM/dd/yyyy" ,
1237+ locale : "en" ,
1238+ } ;
1239+
1240+ const dates = [
1241+ new Date ( "2024-11-14 00:00:00" ) ,
1242+ new Date ( "2024-11-15 00:00:00" ) ,
1243+ new Date ( "2024-11-16 00:00:00" ) ,
1244+ ] ;
1245+
1246+ it ( "should return a blank string when the dates array is null" , ( ) => {
1247+ expect ( safeMultipleDatesFormat ( [ ] , props ) ) . toBe ( "" ) ;
1248+ } ) ;
1249+
1250+ it ( "should return the correct count when multiple dates are selected" , ( ) => {
1251+ expect ( safeMultipleDatesFormat ( dates , props ) ) . toBe ( "11/14/2024 (+2)" ) ;
1252+ } ) ;
1253+
1254+ it ( "should return each selected date when showSelectedCount is false" , ( ) => {
1255+ expect (
1256+ safeMultipleDatesFormat ( dates , { ...props , showSelectedCount : false } ) ,
1257+ ) . toBe ( "11/14/2024, 11/15/2024, 11/16/2024" ) ;
1258+ } ) ;
1259+ } ) ;
1260+
12331261 describe ( "getHolidaysMap" , ( ) => {
12341262 it ( "should return a map of dateClasses" , ( ) => {
12351263 const holidayDates = [
0 commit comments