-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathVideoViewer.test.jsx
More file actions
53 lines (51 loc) · 2.21 KB
/
VideoViewer.test.jsx
File metadata and controls
53 lines (51 loc) · 2.21 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
import { render, screen } from '@tests/utils/test-utils';
import { VideoViewer } from '../../../src/components/VideoViewer';
/** create wrapper */
function createWrapper(props, suspenseFallback) {
return render(
<VideoViewer
classes={{}}
videoOptions={{ crossOrigin: 'anonymous', 'data-testid': 'video' }}
{...props}
/>,
);
}
describe('VideoViewer', () => {
describe('render', () => {
it('videoResources', () => {
createWrapper({
videoResources: [
{ getFormat: () => 'video/mp4', id: 1 },
{ getFormat: () => 'video/mp4', id: 2 },
],
}, true);
const video = screen.getByTestId('video');
expect(video.querySelector('source:nth-of-type(1)')).toHaveAttribute('type', 'video/mp4'); // eslint-disable-line testing-library/no-node-access
expect(video.querySelector('source:nth-of-type(2)')).toHaveAttribute('type', 'video/mp4'); // eslint-disable-line testing-library/no-node-access
});
it('passes through configurable options', () => {
createWrapper({
videoResources: [
{ getFormat: () => 'video/mp4', id: 1 },
],
}, true);
expect(screen.getByTestId('video')).toHaveAttribute('crossOrigin', 'anonymous');
});
it('captions', () => {
createWrapper({
captions: [
{ getDefaultLabel: () => 'English', getProperty: () => 'en', id: 1 },
{ getDefaultLabel: () => 'French', getProperty: () => 'fr', id: 2 },
],
videoResources: [
{ getFormat: () => 'video/mp4', id: 1 },
],
}, true);
const video = screen.getByTestId('video');
expect(video.querySelector('track:nth-of-type(1)')).toHaveAttribute('srcLang', 'en'); // eslint-disable-line testing-library/no-node-access
expect(video.querySelector('track:nth-of-type(1)')).toHaveAttribute('label', 'English'); // eslint-disable-line testing-library/no-node-access
expect(video.querySelector('track:nth-of-type(2)')).toHaveAttribute('srcLang', 'fr'); // eslint-disable-line testing-library/no-node-access
expect(video.querySelector('track:nth-of-type(2)')).toHaveAttribute('label', 'French'); // eslint-disable-line testing-library/no-node-access
});
});
});