-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathTextViewer.test.jsx
More file actions
47 lines (45 loc) · 1.54 KB
/
TextViewer.test.jsx
File metadata and controls
47 lines (45 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
47
import { render, screen } from '@tests/utils/test-utils';
import { TextViewer } from '../../../src/components/TextViewer';
/** create wrapper */
function createWrapper(props, suspenseFallback) {
return render(
<TextViewer
classes={{}}
textOptions={{ crossOrigin: 'anonymous', 'data-testid': 'text' }}
{...props}
/>,
);
}
describe('TextViewer', () => {
describe('render', () => {
it('textResources as source elements', () => {
createWrapper({
textResources: [
{ getFormat: () => 'application/pdf', getType: () => 'Text', id: 1 },
],
windowId: 'a',
}, true);
const text = screen.getByTestId('text');
expect(text.querySelector('source:nth-of-type(1)')).toHaveAttribute('type', 'application/pdf'); // eslint-disable-line testing-library/no-node-access
});
it('passes through configurable options', () => {
createWrapper({
textResources: [
{ getFormat: () => 'application/pdf', getType: () => 'Text', id: 1 },
],
windowId: 'a',
}, true);
expect(screen.getByTestId('text')).toHaveAttribute('crossOrigin', 'anonymous');
});
it('canvas navigation', () => {
createWrapper({
textResources: [
{ getFormat: () => 'application/pdf', getType: () => 'Text', id: 1 },
],
windowId: 'a',
}, true);
const text = screen.getByTestId('text');
expect(text.querySelector('.mirador-canvas-nav')).toBeDefined(); // eslint-disable-line testing-library/no-node-access
});
});
});