* adding more tests - covers article.jsx and elements created from its props and state - added png as static file that needs stubbing * video + channelDetails test coverage * chat + channels tests * channels cc refactor * yarn install * update snapshot and string spacing * chat.jsx test mostly tests rendering elements - does not test imported components, as those are already tested separately - does not imported functions from actions or utils as those will be tested separately as well * cleaning up - mocked response with flush promises for state/component to reflect appropriate changes * snapshot updates
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
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);
|
||
|
||
// check initial state
|
||
expect(context.state()).toEqual({
|
||
leftPx: 200,
|
||
topPx: 200,
|
||
pageX: null,
|
||
pageY: null,
|
||
token: null,
|
||
room: null,
|
||
participants: [],
|
||
});
|
||
});
|
||
});
|