@@ -403,6 +403,25 @@ describe("Calendar", () => {
403403 expect ( nextButtonAriaLabel ) . toBe ( nextButtonAriaLabel ) ;
404404 } ) ;
405405
406+ it ( "should render by default aria labels for next and prev months buttons when providing a react node" , ( ) => {
407+ const previousMonthButtonLabel = < span > Custom react previous month</ span > ;
408+ const nextMonthButtonLabel = < span > Custom react next month</ span > ;
409+ const { calendar } = getCalendar ( {
410+ previousMonthButtonLabel,
411+ nextMonthButtonLabel,
412+ } ) ;
413+
414+ const previousButtonAriaLabel = calendar
415+ . querySelector ( ".react-datepicker__navigation--previous" )
416+ ?. getAttribute ( "aria-label" ) ;
417+ const nextButtonAriaLabel = calendar
418+ . querySelector ( ".react-datepicker__navigation--next" )
419+ ?. getAttribute ( "aria-label" ) ;
420+
421+ expect ( previousButtonAriaLabel ) . toBe ( "Previous Month" ) ;
422+ expect ( nextButtonAriaLabel ) . toBe ( "Next Month" ) ;
423+ } ) ;
424+
406425 it ( "should render the correct default aria labels for next and prev year buttons" , ( ) => {
407426 const { calendar } = getCalendar ( { showYearPicker : true } ) ;
408427 const previousButtonAriaLabel = calendar
@@ -458,6 +477,26 @@ describe("Calendar", () => {
458477 expect ( nextButtonAriaLabel ) . toBe ( nextYearAriaLabel ) ;
459478 } ) ;
460479
480+ it ( "should render by default aria labels for next and prev year buttons when providing a react node" , ( ) => {
481+ const previousYearButtonLabel = < span > Custom react previous year</ span > ;
482+ const nextYearButtonLabel = < span > Custom react next year</ span > ;
483+ const { calendar } = getCalendar ( {
484+ showYearPicker : true ,
485+ previousYearButtonLabel,
486+ nextYearButtonLabel,
487+ } ) ;
488+
489+ const previousButtonAriaLabel = calendar
490+ . querySelector ( ".react-datepicker__navigation--previous" )
491+ ?. getAttribute ( "aria-label" ) ;
492+ const nextButtonAriaLabel = calendar
493+ . querySelector ( ".react-datepicker__navigation--next" )
494+ ?. getAttribute ( "aria-label" ) ;
495+
496+ expect ( previousButtonAriaLabel ) . toBe ( "Previous Year" ) ;
497+ expect ( nextButtonAriaLabel ) . toBe ( "Next Year" ) ;
498+ } ) ;
499+
461500 it ( "should not have previous month button when selecting a date in the second month, when min date is specified" , ( ) => {
462501 const minDate = new Date ( "2024-11-06" ) ;
463502 const maxDate = new Date ( "2025-01-01" ) ;
0 commit comments