Skip to content

Commit ea56b3f

Browse files
authored
feat: validate output HTML (#2475)
* Remove unnecessary `role` attributes * Add missing type=“button” * Add scope=“col” * Add test to validate HTML * Add scope=“row” to week number * Tests: update gridcell vs cell * Update snapshots
1 parent d9d2e5a commit ea56b3f

File tree

14 files changed

+311
-172
lines changed

14 files changed

+311
-172
lines changed

examples/Input.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function textbox() {
1313
}
1414

1515
function gridcells() {
16-
return screen.queryAllByRole("gridcell") as HTMLTableCellElement[];
16+
return screen.queryAllByRole("cell") as HTMLTableCellElement[];
1717
}
1818

1919
function selectedCells() {

examples/ModifiersHidden.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ afterAll(() => jest.useRealTimers());
1818
test.each(days)("the day %s should be hidden", (day) => {
1919
render(<ModifiersHidden />);
2020
expect(
21-
screen.queryByRole("gridcell", { name: `${day.getDate()}` })
21+
screen.queryByRole("cell", { name: `${day.getDate()}` })
2222
).not.toBeInTheDocument();
2323
});

examples/Range.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe("when a day in the range is clicked", () => {
6161
});
6262

6363
function getAllSelected() {
64-
const gridcells = screen.getAllByRole("gridcell");
64+
const gridcells = screen.getAllByRole("cell");
6565

6666
return Array.from(gridcells).filter(
6767
(gridcell) => gridcell.getAttribute("aria-selected") === "true"

examples/Weeknumber.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const today = new Date(2021, 10, 25);
99
beforeAll(() => jest.setSystemTime(today));
1010
afterAll(() => jest.useRealTimers());
1111

12-
function getWeekButton(week: number) {
12+
function getWeek(week: number) {
1313
return screen.getByRole("rowheader", {
1414
name: `Week ${week}`
1515
});
@@ -19,6 +19,6 @@ beforeEach(() => render(<Weeknumber />).container);
1919

2020
describe("when displaying November 2021", () => {
2121
test("should display the 45th week number", () => {
22-
expect(getWeekButton(45)).toBeInTheDocument();
22+
expect(getWeek(45)).toBeInTheDocument();
2323
});
2424
});

examples/WeeknumberCustom.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export function WeeknumberCustom() {
1313
defaultMonth={addMonths(today, -1)}
1414
components={{
1515
WeekNumber: ({ week, ...props }: WeekNumberProps) => (
16-
<td {...props}>
16+
<th {...props}>
1717
<button onClick={() => console.log(week)}>{props.children}</button>
18-
</td>
18+
</th>
1919
)
2020
}}
2121
labels={{

0 commit comments

Comments
 (0)