docbrown/app/javascript/chat/__tests__/VideoContent.test.jsx
Nick Taylor 8e1dd6e323
[deploy] Fixed broken video capabilities of Connect (#8922)
* Fixes the broken video capabilities of Connect.

* Added tests for fullscreen check.

* Added tests.

* Fixed a typo.

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2020-06-26 11:32:34 -04:00

77 lines
2 KiB
JavaScript

import { h } from 'preact';
import { axe } from 'jest-axe';
import { render } from '@testing-library/preact';
import { VideoContent } from '../videoContent';
describe('<VideoContent />', () => {
it('should have no a11y violations', async () => {
const { container } = render(
<VideoContent
videoPath="/some-video-path"
fullscreen="false"
onTriggerVideoContent={jest.fn()}
/>,
);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it('should render in fullscreen', () => {
const { queryByLabelText } = render(
<VideoContent
videoPath="/some-video-path"
fullscreen
onTriggerVideoContent={jest.fn()}
/>,
);
expect(queryByLabelText('Leave fullscreen')).toBeNull();
expect(queryByLabelText('Fullscreen')).toBeDefined();
});
it('should not render in fullscreen', () => {
const { queryByLabelText } = render(
<VideoContent
videoPath="/some-video-path"
fullscreen={false}
onTriggerVideoContent={jest.fn()}
/>,
);
expect(queryByLabelText('Fullscreen')).toBeNull();
expect(queryByLabelText('Leave fullscreen')).toBeDefined();
});
it('should trigger video content when clicked', () => {
const onTriggerVideoContent = jest.fn();
const { getByTestId } = render(
<VideoContent
videoPath="/some-video-path"
fullscreen
onTriggerVideoContent={onTriggerVideoContent}
/>,
);
getByTestId('connect-video').click();
expect(onTriggerVideoContent).toHaveBeenCalledTimes(1);
});
it('should load the given video', () => {
const onTriggerVideoContent = jest.fn();
const { getByTitle } = render(
<VideoContent
videoPath="/some-video-path"
fullscreen
onTriggerVideoContent={onTriggerVideoContent}
/>,
);
const videoFrame = getByTitle('Video display');
expect(videoFrame.getAttribute('src')).toEqual('/some-video-path');
});
});