-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy pathWindowListButton.test.jsx
More file actions
43 lines (33 loc) · 1.39 KB
/
WindowListButton.test.jsx
File metadata and controls
43 lines (33 loc) · 1.39 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
42
43
import { render, screen, within } from '@tests/utils/test-utils';
import userEvent from '@testing-library/user-event';
import { WindowListButton } from '../../../src/components/WindowListButton';
/**
* Helper function to create a shallow wrapper around WindowListButton
*/
function createWrapper(props) {
return render(
<WindowListButton
windowCount={3}
{...props}
/>,
{ preloadedState: { workspace: { windowIds: ['abc123'] } } },
);
}
describe('WindowListButton', () => {
it('shows the window count as a badge on the button', () => {
createWrapper();
expect(within(screen.getByRole('button')).getByText('3', { container: '.MuiBadge-badge' })).toBeInTheDocument();
});
it('disabled the MiradorMenuButton if the disabled prop is true', () => {
createWrapper({ disabled: true });
expect(screen.getByRole('button')).toBeDisabled();
});
it('toggles the WindowList comonent when clicking on the MiradorMenuButton', async () => {
const user = userEvent.setup();
createWrapper();
await user.click(screen.getByRole('button'));
expect(screen.getByText('Current open windows', { container: '.MuiListSubheader-root' })).toBeInTheDocument();
await user.click(screen.getByRole('menuitem', { name: '[Untitled]' }));
expect(screen.queryByText('Current open windows', { container: '.MuiListSubheader-root' })).not.toBeInTheDocument();
});
});