edited tests for no fail and added new Tag test
This commit is contained in:
		@@ -22,7 +22,7 @@ describe('<Preview/>', function () {
 | 
			
		||||
        const wrapper = shallow(<Preview/>);
 | 
			
		||||
        wrapper.setProps({
 | 
			
		||||
            viewbinding: {
 | 
			
		||||
                showVideo: () => {
 | 
			
		||||
                changeRootElement: () => {
 | 
			
		||||
                    func()
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,14 @@ import "@testing-library/jest-dom"
 | 
			
		||||
import {shallow} from 'enzyme'
 | 
			
		||||
 | 
			
		||||
describe('<Tag/>', function () {
 | 
			
		||||
    function prepareFetchApi(response) {
 | 
			
		||||
        const mockJsonPromise = Promise.resolve(response);
 | 
			
		||||
        const mockFetchPromise = Promise.resolve({
 | 
			
		||||
            json: () => mockJsonPromise,
 | 
			
		||||
        });
 | 
			
		||||
        return (jest.fn().mockImplementation(() => mockFetchPromise));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    it('renders without crashing ', function () {
 | 
			
		||||
        const wrapper = shallow(<Tag>test</Tag>);
 | 
			
		||||
        wrapper.unmount();
 | 
			
		||||
@@ -14,4 +22,22 @@ describe('<Tag/>', function () {
 | 
			
		||||
        const wrapper = shallow(<Tag>test</Tag>);
 | 
			
		||||
        expect(wrapper.children().text()).toBe("test");
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('click event triggered and setvideo callback called', done => {
 | 
			
		||||
        global.fetch = prepareFetchApi({});
 | 
			
		||||
        const func = jest.fn();
 | 
			
		||||
 | 
			
		||||
        const wrapper = shallow(<Tag
 | 
			
		||||
            contentbinding={func}>test</Tag>);
 | 
			
		||||
 | 
			
		||||
        wrapper.simulate("click");
 | 
			
		||||
 | 
			
		||||
        process.nextTick(() => {
 | 
			
		||||
            // state to be set correctly with response
 | 
			
		||||
            expect(func).toBeCalledTimes(1);
 | 
			
		||||
 | 
			
		||||
            global.fetch.mockClear();
 | 
			
		||||
            done();
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import {shallow} from "enzyme";
 | 
			
		||||
import {shallow, mount} from "enzyme";
 | 
			
		||||
import React from "react";
 | 
			
		||||
import HomePage from "./HomePage";
 | 
			
		||||
import VideoContainer from "../../elements/VideoContainer/VideoContainer";
 | 
			
		||||
@@ -23,7 +23,8 @@ describe('<HomePage/>', function () {
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('ckeck default tag click events', function () {
 | 
			
		||||
        const wrapper = shallow(<HomePage/>);
 | 
			
		||||
        // todo mount bad here maybe delete this test
 | 
			
		||||
        const wrapper = mount(<HomePage/>);
 | 
			
		||||
        global.fetch = prepareFetchApi({});
 | 
			
		||||
 | 
			
		||||
        expect(global.fetch).toBeCalledTimes(0);
 | 
			
		||||
 
 | 
			
		||||
@@ -99,7 +99,7 @@ describe('<Player/>', function () {
 | 
			
		||||
 | 
			
		||||
        wrapper.setProps({
 | 
			
		||||
            viewbinding: {
 | 
			
		||||
                hideVideo: () => {
 | 
			
		||||
                returnToLastElement: () => {
 | 
			
		||||
                    func()
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user