diff --git a/app/javascript/chat/__tests__/VideoContent.test.jsx b/app/javascript/chat/__tests__/VideoContent.test.jsx new file mode 100644 index 000000000..852499038 --- /dev/null +++ b/app/javascript/chat/__tests__/VideoContent.test.jsx @@ -0,0 +1,77 @@ +import { h } from 'preact'; +import { axe } from 'jest-axe'; +import { render } from '@testing-library/preact'; +import { VideoContent } from '../videoContent'; + +describe('', () => { + it('should have no a11y violations', async () => { + const { container } = render( + , + ); + const results = await axe(container); + + expect(results).toHaveNoViolations(); + }); + + it('should render in fullscreen', () => { + const { queryByLabelText } = render( + , + ); + + expect(queryByLabelText('Leave fullscreen')).toBeNull(); + expect(queryByLabelText('Fullscreen')).toBeDefined(); + }); + + it('should not render in fullscreen', () => { + const { queryByLabelText } = render( + , + ); + + expect(queryByLabelText('Fullscreen')).toBeNull(); + expect(queryByLabelText('Leave fullscreen')).toBeDefined(); + }); + + it('should trigger video content when clicked', () => { + const onTriggerVideoContent = jest.fn(); + + const { getByTestId } = render( + , + ); + + getByTestId('connect-video').click(); + + expect(onTriggerVideoContent).toHaveBeenCalledTimes(1); + }); + + it('should load the given video', () => { + const onTriggerVideoContent = jest.fn(); + + const { getByTitle } = render( + , + ); + + const videoFrame = getByTitle('Video display'); + + expect(videoFrame.getAttribute('src')).toEqual('/some-video-path'); + }); +}); diff --git a/app/javascript/chat/chat.jsx b/app/javascript/chat/chat.jsx index 511f86604..a6c7612c0 100644 --- a/app/javascript/chat/chat.jsx +++ b/app/javascript/chat/chat.jsx @@ -36,7 +36,7 @@ import Compose from './compose'; import Message from './message'; import ActionMessage from './actionMessage'; import Content from './content'; -import VideoContent from './videoContent'; +import { VideoContent } from './videoContent'; export default class Chat extends Component { static propTypes = { diff --git a/app/javascript/chat/videoContent.jsx b/app/javascript/chat/videoContent.jsx index 5d8794231..b202e7718 100644 --- a/app/javascript/chat/videoContent.jsx +++ b/app/javascript/chat/videoContent.jsx @@ -1,55 +1,69 @@ -import { h, Component } from 'preact'; +import { h } from 'preact'; -export default class VideoContent extends Component { - render() { - if (!this.props.videoPath) { - return ''; - } +const smartSvgIcon = (content, d) => ( + + + + +); - const smartSvgIcon = (content, d) => ( - - - - - ); - return ( -
- - -