Skip to content

Commit

Permalink
add tests for aria-controls and aria-labelledby
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Sep 29, 2024
1 parent 7146b88 commit 293599d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/bits-ui/src/tests/tabs/tabs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,29 @@ describe("tabs", () => {
expect(content1).not.toBeVisible();
expect(content3).toBeVisible();
});

it("should apply appropriate `aria-controls` and `aria-labelledby` attributes to the `Tabs.Trigger` and `Tabs.Content` components", async () => {
const { getByTestId } = setup();
const triggers = [
getByTestId("trigger-1"),
getByTestId("trigger-2"),
getByTestId("trigger-3"),
];

const contents = [
getByTestId("content-1"),
getByTestId("content-2"),
getByTestId("content-3"),
];

for (let i = 0; i < triggers.length; i++) {
const trigger = triggers[i]!;
const content = contents[i]!;

expect(content).toHaveAttribute("role", "tabpanel");
expect(trigger).toHaveAttribute("role", "tab");
expect(trigger.getAttribute("aria-controls")).toBe(content.id);
expect(content.getAttribute("aria-labelledby")).toBe(trigger.id);
}
});
});

0 comments on commit 293599d

Please sign in to comment.