From 3106ed5690b5b8284d599f1ca6ab189fe4f31bdf Mon Sep 17 00:00:00 2001 From: Giampaolo Bellavite Date: Sun, 14 Jul 2024 09:17:42 -0500 Subject: [PATCH] fix(accessibility): update labels, add more tests --- examples/DropdownMultipleMonths.test.tsx | 6 ++++-- examples/__snapshots__/Range.test.tsx.snap | 12 ++++++------ .../StylingCssModules.test.tsx.snap | 6 +++--- src/DayPicker.tsx | 7 +++++-- src/labels/labelDayButton.test.ts | 17 +++++++++++++++++ src/labels/labelGrid.test.ts | 7 +++++++ src/labels/labelGridcell.test.ts | 7 +++++++ src/labels/labelMonthDropdown.test.ts | 2 +- src/labels/labelMonthDropdown.ts | 2 +- src/labels/labelNav.test.ts | 5 +++++ src/labels/labelNext.test.ts | 2 +- src/labels/labelNext.ts | 2 +- src/labels/labelPrevious.test.ts | 2 +- src/labels/labelPrevious.ts | 2 +- src/labels/labelYearDropdown.test.ts | 2 +- src/labels/labelYearDropdown.ts | 2 +- test/elements.ts | 14 ++++++++------ 17 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 src/labels/labelGrid.test.ts create mode 100644 src/labels/labelGridcell.test.ts create mode 100644 src/labels/labelNav.test.ts diff --git a/examples/DropdownMultipleMonths.test.tsx b/examples/DropdownMultipleMonths.test.tsx index d9fb2e4586..f8bd58df63 100644 --- a/examples/DropdownMultipleMonths.test.tsx +++ b/examples/DropdownMultipleMonths.test.tsx @@ -1,5 +1,7 @@ import React from "react"; +import { labelMonthDropdown } from "react-day-picker"; + import { grid } from "@/test/elements"; import { screen, render } from "@/test/render"; import { user } from "@/test/user"; @@ -19,7 +21,7 @@ describe("when choosing a month from the first dropdown", () => { const monthName = "January"; beforeEach(async () => { const firstDropDown = screen.getAllByRole("combobox", { - name: "Month:" + name: labelMonthDropdown() })[0]; await user.selectOptions(firstDropDown, monthName); }); @@ -32,7 +34,7 @@ describe("when choosing a month from the third dropdown", () => { const newMonthName = "October"; beforeEach(async () => { const thirdDropDown = screen.getAllByRole("combobox", { - name: "Month:" + name: labelMonthDropdown() })[2]; await user.selectOptions(thirdDropDown, newMonthName); }); diff --git a/examples/__snapshots__/Range.test.tsx.snap b/examples/__snapshots__/Range.test.tsx.snap index 8757be7a96..037832efb7 100644 --- a/examples/__snapshots__/Range.test.tsx.snap +++ b/examples/__snapshots__/Range.test.tsx.snap @@ -14,11 +14,11 @@ exports[`should match the snapshot 1`] = `