-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathCanvasInfo.test.jsx
More file actions
55 lines (45 loc) · 1.73 KB
/
CanvasInfo.test.jsx
File metadata and controls
55 lines (45 loc) · 1.73 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
import { render, screen } from '@tests/utils/test-utils';
import userEvent from '@testing-library/user-event';
import { CanvasInfo } from '../../../src/components/CanvasInfo';
describe('CanvasInfo', () => {
const metadata = [{ label: 'some label', values: ['some value'] }];
let user;
describe('when metadata is present', () => {
beforeEach(() => {
user = userEvent.setup();
render(
<CanvasInfo
canvasLabel="The Canvas Label"
canvasDescription="The Canvas Description"
canvasMetadata={metadata}
/>,
);
});
it('renders the content in a CollapsibleSection', async () => {
expect(screen.getByRole('heading', { level: 4 })).toHaveTextContent('Current item');
expect(screen.getByRole('heading', { level: 5 })).toHaveTextContent(/The Canvas Label/);
await user.click(screen.getByRole('button'));
expect(screen.queryByRole('heading', { level: 5 })).not.toBeInTheDocument();
});
it('renders canvas label', () => {
expect(screen.getByRole('heading', { level: 5 })).toHaveTextContent(/The Canvas Label/);
});
it('renders canvas description', () => {
expect(screen.getByText('The Canvas Description')).toBeInTheDocument();
});
it('renders canvas metadata in LabelValueMetadata component', () => {
expect(screen.getByText('some label')).toBeInTheDocument();
expect(screen.getByText('some value')).toBeInTheDocument();
});
});
describe('when metadata is not present', () => {
beforeEach(() => {
render(
<CanvasInfo />,
);
});
it('does not render empty elements elements', () => {
expect(screen.queryByRole('heading', { level: 5 })).not.toBeInTheDocument();
});
});
});