docbrown/app/javascript/chat/__tests__/video.test.jsx
Ben Halpern 70580d0265
[WIP] Connect misc improvements/debugs (#2880)
* WIP Connect misc improvements/debugs

* Modify tests and update snapshots

* Change GitHub sidecar copy
2019-05-20 10:08:51 -04:00

37 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { h } from 'preact';
import render from 'preact-render-to-json';
import { deep } from 'preact-render-spy';
import fetch from 'jest-fetch-mock';
import Video from '../video';
global.fetch = fetch;
let exited;
exited = false;
const exitVideo = () => {
exited = true;
};
describe('<Video />', () => {
it('should render properly and test snapshot', () => {
const tree = render(<Video activeChannelId={12345} onExit={exitVideo} />);
expect(tree).toMatchSnapshot();
});
it('should have the proper elements, classes and information', () => {
const context = deep(<Video activeChannelId={12345} onExit={exitVideo} />);
// check elements
expect(context.find('.chat__videocall').exists()).toEqual(true);
expect(context.find('.chat__remotevideoscreen-0').exists()).toEqual(true);
expect(context.find('.chat__localvideoscren').exists()).toEqual(true);
const exitButton = context.find('.chat__videocallexitbutton');
expect(exitButton.exists()).toEqual(true);
expect(exitButton.text()).toEqual('×');
// test exit button behaves
exitButton.simulate('click');
expect(exited).toEqual(true);
});
});