-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathWorkspaceOptionsButton.test.jsx
More file actions
41 lines (35 loc) · 1.14 KB
/
WorkspaceOptionsButton.test.jsx
File metadata and controls
41 lines (35 loc) · 1.14 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
import { render, screen } from '@tests/utils/test-utils';
import userEvent from '@testing-library/user-event';
import { WorkspaceOptionsButton } from '../../../src/components/WorkspaceOptionsButton';
/** create wrapper */
function Subject({ ...props }) {
return (
<div>
<WorkspaceOptionsButton
classes={{}}
{...props}
/>
,
,
</div>
);
}
describe('WorkspaceOptionsButton', () => {
let user;
beforeEach(() => {
user = userEvent.setup();
});
it('renders the button', () => {
render(<Subject />);
expect(screen.getByLabelText('Workspace options')).toBeInTheDocument();
});
it('toggles open/close of <WorkspaceOptionsMenu /> when clicked', async () => {
render(<Subject />);
expect(screen.queryByRole('menu')).not.toBeInTheDocument();
await user.click(screen.getByLabelText('Workspace options'));
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();
});
});