-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathWorkspaceMenuButton.test.jsx
More file actions
29 lines (23 loc) · 1012 Bytes
/
WorkspaceMenuButton.test.jsx
File metadata and controls
29 lines (23 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { render, screen } from '@tests/utils/test-utils';
import userEvent from '@testing-library/user-event';
import { WorkspaceMenuButton } from '../../../src/components/WorkspaceMenuButton';
describe('WorkspaceMenuButton', () => {
let user;
beforeEach(() => {
user = userEvent.setup();
render(
<WorkspaceMenuButton classes={{ ctrlBtnSelected: 'ctrlBtnSelected' }} />,
);
});
it('renders the button', () => {
expect(screen.getByRole('button')).toHaveAccessibleName('Workspace settings');
});
it('toggles open/close of <WorkspaceOptionsMenu /> when clicked', async () => {
expect(screen.queryByRole('menu')).not.toBeInTheDocument();
await user.click(screen.getByRole('button'));
expect(screen.getByRole('menu')).toBeInTheDocument();
// click something else to close the menu (the windowMenu button is hidden at this point)
await user.click(screen.getAllByRole('menuitem')[0]);
expect(screen.queryByRole('menu')).not.toBeInTheDocument();
});
});