Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl committed Nov 30, 2024
1 parent 5e1dc19 commit 0c24ead
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 180 deletions.
4 changes: 2 additions & 2 deletions examples/FixedWeeks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ beforeEach(() => {
render(<FixedWeeks />);
});

test("should render 7 rows", () => {
expect(screen.getAllByRole("row")).toHaveLength(7);
test("should render 6 rows", () => {
expect(screen.getAllByRole("row")).toHaveLength(6);
});
2 changes: 1 addition & 1 deletion examples/Input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function textbox() {
}

function gridcells() {
return screen.queryAllByRole("cell") as HTMLTableCellElement[];
return screen.queryAllByRole("gridcell") as HTMLTableCellElement[];
}

function selectedCells() {
Expand Down
2 changes: 1 addition & 1 deletion examples/ModifiersHidden.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ afterAll(() => jest.useRealTimers());
test.each(days)("the day %s should be hidden", (day) => {
render(<ModifiersHidden />);
expect(
screen.queryByRole("cell", { name: `${day.getDate()}` })
screen.queryByRole("gridcell", { name: `${day.getDate()}` })
).not.toBeInTheDocument();
});
2 changes: 1 addition & 1 deletion examples/Range.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("when a day in the range is clicked", () => {
});

function getAllSelected() {
const gridcells = screen.getAllByRole("cell");
const gridcells = screen.getAllByRole("gridcell");

return Array.from(gridcells).filter(
(gridcell) => gridcell.getAttribute("aria-selected") === "true"
Expand Down
4 changes: 3 additions & 1 deletion examples/TestCase2511.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ beforeEach(async () => {
});

test("first weekday is Monday", () => {
const weekdaysElements = screen.queryAllByRole("columnheader");
const weekdaysElements = screen.queryAllByRole("columnheader", {
hidden: true
});
expect(weekdaysElements[0]).toHaveAccessibleName("Monday");
});
4 changes: 2 additions & 2 deletions examples/TestCase2585.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import { TestCase2585 } from "./TestCase2585";

render(<TestCase2585 />);

test("should render 42*12 days", () => {
expect(screen.getAllByRole("cell")).toHaveLength(42 * 12);
test("should render 48*12 days", () => {
expect(screen.getAllByRole("gridcell")).toHaveLength(48 * 12);
});
4 changes: 3 additions & 1 deletion examples/Weeknumber.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ afterAll(() => jest.useRealTimers());

function getWeek(week: number) {
return screen.getByRole("rowheader", {
name: `Week ${week}`
name: (name, el) =>
name === `Week number` && el.textContent === week.toString(),
hidden: true
});
}

Expand Down
6 changes: 5 additions & 1 deletion examples/WeeknumberCustom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ beforeEach(() => {
});

test("should display the 1st week (even if December)", () => {
expect(screen.getByRole("rowheader", { name: `W1` })).toBeInTheDocument();
expect(
screen.getByRole("rowheader", {
name: (name, el) => name === "W1"
})
).toBeInTheDocument();
});
Loading

0 comments on commit 0c24ead

Please sign in to comment.