fix some tests
fix merge issues
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import {shallow} from 'enzyme';
|
||||
import React from 'react';
|
||||
import HomePage from './HomePage';
|
||||
import {HomePage} from './HomePage';
|
||||
import VideoContainer from '../../elements/VideoContainer/VideoContainer';
|
||||
import {SearchHandling} from './SearchHandling';
|
||||
|
||||
describe('<HomePage/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
@@ -54,23 +55,15 @@ describe('<HomePage/>', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('test form submit', done => {
|
||||
global.fetch = global.prepareFetchApi([{}, {}]);
|
||||
|
||||
it('test form submit', () => {
|
||||
const func = jest.fn();
|
||||
const wrapper = shallow(<HomePage/>);
|
||||
wrapper.setProps({history: {push: () => func()}});
|
||||
|
||||
const fakeEvent = {preventDefault: () => console.log('preventDefault')};
|
||||
wrapper.find('.searchform').simulate('submit', fakeEvent);
|
||||
|
||||
expect(wrapper.state().selectionnr).toBe(0);
|
||||
|
||||
process.nextTick(() => {
|
||||
// state to be set correctly with response
|
||||
expect(wrapper.state().selectionnr).toBe(2);
|
||||
|
||||
global.fetch.mockClear();
|
||||
done();
|
||||
});
|
||||
expect(func).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('test no backend connection behaviour', done => {
|
||||
@@ -123,3 +116,24 @@ describe('<HomePage/>', function () {
|
||||
testBtn(tags.first());
|
||||
});
|
||||
});
|
||||
|
||||
describe('<SearchHandling/>', () => {
|
||||
it('renders without crashing', function () {
|
||||
const wrapper = shallow(<SearchHandling match={{params: {name: 'testname'}}}/>);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('renders videos correctly into container', function () {
|
||||
const wrapper = shallow(<SearchHandling match={{params: {name: 'testname'}}}/>);
|
||||
|
||||
wrapper.setState({
|
||||
data: [{
|
||||
movie_id: 42,
|
||||
movie_name: 'testname'
|
||||
}]
|
||||
});
|
||||
|
||||
// expect video container to be visible
|
||||
expect(wrapper.find('VideoContainer')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user