Skip to content

Commit

Permalink
chore: aria 속성 변경에 따른 테스트 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SeieunYoo committed Sep 22, 2024
1 parent d9f3b89 commit 9047f30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
24 changes: 10 additions & 14 deletions packages/wow-ui/src/components/DropDown/DropDown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ describe("DropDown component", () => {
placeholder: "Please select",
});

const dropdownButton = screen.getByRole("button", {
name: "Option 2 down-arrow icon",
});
expect(dropdownButton).toBeInTheDocument();
expect(dropdownButton).toHaveAttribute("id", `${dropdownId}-trigger`);
expect(dropdownButton).toHaveTextContent("Option 2");
const dropdownTrigger = screen.getByRole("combobox");
expect(dropdownTrigger).toHaveTextContent("Option 2");
});

it("should render the trigger button", async () => {
Expand Down Expand Up @@ -159,35 +155,35 @@ describe("external control and events", () => {

await userEvent.keyboard("{ArrowDown}");
await waitFor(() => {
const dropdown = screen.getByRole("listbox");
expect(dropdown).toHaveAttribute(
const dropdownTrigger = screen.getByRole("combobox");
expect(dropdownTrigger).toHaveAttribute(
"aria-activedescendant",
`${dropdownId}-option-option1`
);
});

await userEvent.keyboard("{ArrowDown}");
await waitFor(() => {
const dropdown = screen.getByRole("listbox");
expect(dropdown).toHaveAttribute(
const dropdownTrigger = screen.getByRole("combobox");
expect(dropdownTrigger).toHaveAttribute(
"aria-activedescendant",
`${dropdownId}-option-option2`
);
});

await userEvent.keyboard("{ArrowDown}");
await waitFor(() => {
const dropdown = screen.getByRole("listbox");
expect(dropdown).toHaveAttribute(
const dropdownTrigger = screen.getByRole("combobox");
expect(dropdownTrigger).toHaveAttribute(
"aria-activedescendant",
`${dropdownId}-option-option3`
);
});

await userEvent.keyboard("{ArrowUp}");
await waitFor(() => {
const dropdown = screen.getByRole("listbox");
expect(dropdown).toHaveAttribute(
const dropdownTrigger = screen.getByRole("combobox");
expect(dropdownTrigger).toHaveAttribute(
"aria-activedescendant",
`${dropdownId}-option-option2`
);
Expand Down
11 changes: 7 additions & 4 deletions packages/wow-ui/src/components/DropDown/DropDownTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ const DropDownTrigger = ({
...(focusedValue && {
"aria-activedescendant": `${dropdownId}-option-${focusedValue}`,
}),
...(label && {
"aria-labeledby": `${dropdownId}-label`,
}),
...(label
? {
"aria-labelledby": `${dropdownId}-label`,
}
: {
"aria-label": `dropdown-open`,
}),
};

if (trigger) {
Expand All @@ -85,7 +89,6 @@ const DropDownTrigger = ({
alignItems="center"
cursor="pointer"
display="flex"
id={`${dropdownId}-trigger`}
justifyContent="space-between"
outline="none"
type="button"
Expand Down

0 comments on commit 9047f30

Please sign in to comment.