-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { describe, expect, it } from "vitest"; | ||
import { Button } from "../Button"; | ||
import { DialogTrigger } from "../Dialog"; | ||
import { Menu, MenuItem } from "./Menu"; | ||
|
||
describe("Menu", () => { | ||
it("renders Menu with accessible title", async () => { | ||
render( | ||
<DialogTrigger> | ||
<Button>Open Menu</Button> | ||
<Menu> | ||
<MenuItem id="item1">Item 1</MenuItem> | ||
<MenuItem id="item2">Item 2</MenuItem> | ||
</Menu> | ||
</DialogTrigger>, | ||
); | ||
|
||
const button = screen.getByRole("button", { name: "Open Menu" }); | ||
userEvent.click(button); | ||
|
||
// Renders the menu | ||
const menu = await screen.findByRole("menu"); | ||
expect(menu).toBeInTheDocument(); | ||
|
||
// Renders the accessible title | ||
const title = await screen.findByRole("dialog", { | ||
name: "Select an option", | ||
}); | ||
expect(title).toBeInTheDocument(); | ||
}); | ||
}); |