edited tests for no fail and added new Tag test
This commit is contained in:
parent
89153b5da9
commit
4ac21506f3
@ -22,7 +22,7 @@ describe('<Preview/>', function () {
|
|||||||
const wrapper = shallow(<Preview/>);
|
const wrapper = shallow(<Preview/>);
|
||||||
wrapper.setProps({
|
wrapper.setProps({
|
||||||
viewbinding: {
|
viewbinding: {
|
||||||
showVideo: () => {
|
changeRootElement: () => {
|
||||||
func()
|
func()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,14 @@ import "@testing-library/jest-dom"
|
|||||||
import {shallow} from 'enzyme'
|
import {shallow} from 'enzyme'
|
||||||
|
|
||||||
describe('<Tag/>', function () {
|
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 () {
|
it('renders without crashing ', function () {
|
||||||
const wrapper = shallow(<Tag>test</Tag>);
|
const wrapper = shallow(<Tag>test</Tag>);
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
@ -14,4 +22,22 @@ describe('<Tag/>', function () {
|
|||||||
const wrapper = shallow(<Tag>test</Tag>);
|
const wrapper = shallow(<Tag>test</Tag>);
|
||||||
expect(wrapper.children().text()).toBe("test");
|
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 React from "react";
|
||||||
import HomePage from "./HomePage";
|
import HomePage from "./HomePage";
|
||||||
import VideoContainer from "../../elements/VideoContainer/VideoContainer";
|
import VideoContainer from "../../elements/VideoContainer/VideoContainer";
|
||||||
@ -23,7 +23,8 @@ describe('<HomePage/>', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('ckeck default tag click events', 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({});
|
global.fetch = prepareFetchApi({});
|
||||||
|
|
||||||
expect(global.fetch).toBeCalledTimes(0);
|
expect(global.fetch).toBeCalledTimes(0);
|
||||||
|
@ -99,7 +99,7 @@ describe('<Player/>', function () {
|
|||||||
|
|
||||||
wrapper.setProps({
|
wrapper.setProps({
|
||||||
viewbinding: {
|
viewbinding: {
|
||||||
hideVideo: () => {
|
returnToLastElement: () => {
|
||||||
func()
|
func()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user