diff --git a/src/calendar.jsx b/src/calendar.jsx index 6c7c217e9..dca56b404 100644 --- a/src/calendar.jsx +++ b/src/calendar.jsx @@ -444,6 +444,7 @@ export default class Calendar extends React.Component { return (
{weekDayName} diff --git a/test/calendar_test.test.js b/test/calendar_test.test.js index f3fbf4656..8b70b1fd2 100644 --- a/test/calendar_test.test.js +++ b/test/calendar_test.test.js @@ -1882,6 +1882,37 @@ describe("Calendar", () => { }); }); + it("should add the aria-label correctly to day names", () => { + const expectedAriaLabels = [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + ]; + + const { container } = render( + {}} + onClickOutside={() => {}} + />, + ); + + const header = container.querySelector(".react-datepicker__header"); + const dayNameElements = header.querySelectorAll( + ".react-datepicker__day-name", + ); + + dayNameElements.forEach((element, index) => { + expect(element.getAttribute("aria-label")).toBe( + expectedAriaLabels[index], + ); + }); + }); + it("should have a next-button with the provided aria-label for year", () => { const ariaLabel = "A label in my native language for next year"; const { container } = render(