-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathWorkspaceArea.test.jsx
More file actions
59 lines (47 loc) · 2.37 KB
/
WorkspaceArea.test.jsx
File metadata and controls
59 lines (47 loc) · 2.37 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
47
48
49
50
51
52
53
54
55
56
57
58
59
import { render, screen, within } from '@tests/utils/test-utils';
import { DndProvider } from 'react-dnd';
import { TestBackend } from 'react-dnd-test-backend';
import { WorkspaceArea } from '../../../src/components/WorkspaceArea';
/** */
function createWrapper(props) {
return render(
<DndProvider backend={TestBackend}>
<WorkspaceArea
isWorkspaceControlPanelVisible
classes={{}}
lang="en"
{...props}
/>
</DndProvider>,
);
}
describe('WorkspaceArea', () => {
it('should render outer element correctly', () => {
createWrapper();
expect(screen.getByRole('main')).toHaveClass('mirador-viewer');
expect(screen.getByRole('main')).toHaveAttribute('lang', 'en');
});
it('should render all needed elements', () => {
const { container } = createWrapper();
expect(screen.getByRole('button', { name: 'Jump to window' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Workspace settings' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Workspace options' })).toBeInTheDocument();
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Mirador viewer');
expect(screen.getByRole('main')).toHaveTextContent('Welcome to Mirador');
expect(container.querySelector('.mirador-background-plugin-area')).toBeInTheDocument(); // eslint-disable-line testing-library/no-node-access, testing-library/no-container
});
it('should not render WorkspaceControlPanel when isWorkspaceControlPanelVisible is false', () => {
createWrapper({ isWorkspaceControlPanelVisible: false });
expect(screen.queryByRole('button', { name: 'Jump to window' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Workspace settings' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Workspace options' })).not.toBeInTheDocument();
});
describe('with isWorkspaceAddVisible', () => {
it('should render WorkspaceAdd when isWorkspaceAddVisible is true', () => {
createWrapper({ isWorkspaceAddVisible: true });
expect(screen.queryByRole('heading', { level: 1, name: 'Mirador viewer' })).not.toBeInTheDocument();
expect(screen.getByRole('main')).toHaveTextContent('Your resource list is empty');
expect(within(screen.getByRole('main')).getByRole('button', { name: 'Add resource' })).toBeInTheDocument();
});
});
});