-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathWorkspaceAddButton.test.jsx
More file actions
46 lines (37 loc) · 1.54 KB
/
WorkspaceAddButton.test.jsx
File metadata and controls
46 lines (37 loc) · 1.54 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
44
45
46
import { render, screen } from '@tests/utils/test-utils';
import userEvent from '@testing-library/user-event';
import { WorkspaceAddButton } from '../../../src/components/WorkspaceAddButton';
/** create wrapper */
function createWrapper(props) {
return render(
<WorkspaceAddButton
classes={{}}
setWorkspaceAddVisibility={() => {}}
useExtendedFab
{...props}
/>,
);
}
vi.mock('@mui/material/useMediaQuery', () => ({ default: vi.fn().mockReturnValue(true) }));
describe('WorkspaceAddButton', () => {
it('renders a button to open the load window area', async () => {
const user = userEvent.setup();
const setWorkspaceAddVisibility = vi.fn();
createWrapper({ isWorkspaceAddVisible: false, setWorkspaceAddVisibility });
await user.click(screen.getByRole('button', { name: 'Start Here' }));
expect(setWorkspaceAddVisibility).toHaveBeenCalledWith(true);
});
it('renders a button to close the load window area', async () => {
const user = userEvent.setup();
const setWorkspaceAddVisibility = vi.fn();
createWrapper({ isWorkspaceAddVisible: true, setWorkspaceAddVisibility });
await user.click(screen.getByRole('button', { name: 'Close resource list' }));
expect(setWorkspaceAddVisibility).toHaveBeenCalledWith(false);
});
describe('when the useExtendedFab prop is set', () => {
it('is styled using the extended variant', () => {
createWrapper({ useExtendedFab: true });
expect(screen.getByRole('button', { name: 'Start Here' })).toHaveClass('MuiFab-extended');
});
});
});