-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy pathManifestRelatedLinks.test.jsx
More file actions
90 lines (80 loc) · 3.29 KB
/
ManifestRelatedLinks.test.jsx
File metadata and controls
90 lines (80 loc) · 3.29 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { render, screen } from '@tests/utils/test-utils';
import userEvent from '@testing-library/user-event';
import { ManifestRelatedLinks } from '../../../src/components/ManifestRelatedLinks';
describe('ManifestRelatedLinks', () => {
describe('when metadata is present', () => {
beforeEach(() => {
render(
<ManifestRelatedLinks
classes={{}}
id="xyz"
homepage={[
{
label: 'Home page',
value: 'http://example.com/',
},
]}
manifestUrl="http://example.com/"
related={[
{
value: 'http://example.com/related',
},
{
format: 'video/ogg',
label: 'Video',
value: 'http://example.com/video',
},
]}
renderings={[
{
label: 'PDF Version',
value: 'http://example.com/pdf',
},
]}
seeAlso={[
{
format: 'text/html',
label: 'A',
value: 'http://example.com/a',
},
{
label: null,
value: 'http://example.com/b',
},
]}
/>,
);
});
it('renders the content in a CollapsibleSection', async () => {
const user = userEvent.setup();
expect(screen.getByRole('heading', { level: 4 })).toHaveTextContent('Related');
expect(screen.getByRole('heading', { level: 5 })).toHaveTextContent(/Links/);
await user.click(screen.getByRole('button', { name: 'Collapse "Related" section' }));
expect(screen.queryByRole('heading', { level: 5 })).not.toBeInTheDocument();
});
it('renders manifest homepage information', () => {
expect(screen.getByText('About this resource').tagName).toEqual('DT');
expect(screen.getByRole('link', { name: 'Home page' })).toHaveAttribute('href', 'http://example.com/');
});
it('renders manifest renderings information', () => {
expect(screen.getByText('Alternate formats').tagName).toEqual('DT');
expect(screen.getByRole('link', { name: 'PDF Version' })).toHaveAttribute('href', 'http://example.com/pdf');
});
it('renders related information', () => {
expect(screen.getAllByText('Related')[1].tagName).toEqual('DT');
expect(screen.getByRole('link', { name: 'http://example.com/related' })).toHaveAttribute('href', 'http://example.com/related');
expect(screen.getByRole('link', { name: 'Video' })).toHaveAttribute('href', 'http://example.com/video');
expect(screen.getByText('(video/ogg)')).toBeInTheDocument();
});
it('renders manifest seeAlso information', () => {
expect(screen.getByText('See also').tagName).toEqual('DT');
expect(screen.getByRole('link', { name: 'A' })).toHaveAttribute('href', 'http://example.com/a');
expect(screen.getByText('(text/html)')).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'http://example.com/b' })).toHaveAttribute('href', 'http://example.com/b');
});
it('renders manifest links', () => {
expect(screen.getByText('IIIF manifest').tagName).toEqual('DT');
expect(screen.getByRole('link', { name: 'http://example.com/' })).toHaveAttribute('href', 'http://example.com/');
});
});
});