correct sort order of css properties
mocking of fetch api only once in setupTests
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import SideBar, {SideBarTitle, SideBarItem} from "../../elements/SideBar/SideBar";
|
||||
import SideBar, {SideBarItem, SideBarTitle} from "../../elements/SideBar/SideBar";
|
||||
import Tag from "../../elements/Tag/Tag";
|
||||
import VideoContainer from "../../elements/VideoContainer/VideoContainer";
|
||||
|
||||
@ -7,6 +7,9 @@ import style from "./HomePage.module.css"
|
||||
import PageTitle from "../../elements/PageTitle/PageTitle";
|
||||
|
||||
class HomePage extends React.Component {
|
||||
/** keyword variable needed temporary store search keyword */
|
||||
keyword = "";
|
||||
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
|
||||
@ -24,9 +27,6 @@ class HomePage extends React.Component {
|
||||
};
|
||||
}
|
||||
|
||||
/** keyword variable needed temporary store search keyword */
|
||||
keyword = "";
|
||||
|
||||
componentDidMount() {
|
||||
// initial get of all videos
|
||||
this.fetchVideoData("all");
|
||||
|
@ -4,6 +4,6 @@
|
||||
}
|
||||
|
||||
.searchform {
|
||||
margin-top: 25px;
|
||||
float: right;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
@ -3,19 +3,6 @@ import React from "react";
|
||||
import HomePage from "./HomePage";
|
||||
import VideoContainer from "../../elements/VideoContainer/VideoContainer";
|
||||
|
||||
function prepareFetchApi(response) {
|
||||
const mockJsonPromise = Promise.resolve(response);
|
||||
const mockFetchPromise = Promise.resolve({
|
||||
json: () => mockJsonPromise,
|
||||
});
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
|
||||
function prepareFailingFetchApi() {
|
||||
const mockFetchPromise = Promise.reject("myreason");
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
|
||||
describe('<HomePage/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<HomePage/>);
|
||||
@ -51,7 +38,7 @@ describe('<HomePage/>', function () {
|
||||
});
|
||||
|
||||
it('test search field', done => {
|
||||
global.fetch = prepareFetchApi([{}, {}]);
|
||||
global.fetch = global.prepareFetchApi([{}, {}]);
|
||||
|
||||
const wrapper = shallow(<HomePage/>);
|
||||
|
||||
@ -68,7 +55,7 @@ describe('<HomePage/>', function () {
|
||||
});
|
||||
|
||||
it('test form submit', done => {
|
||||
global.fetch = prepareFetchApi([{}, {}]);
|
||||
global.fetch = global.prepareFetchApi([{}, {}]);
|
||||
|
||||
const wrapper = shallow(<HomePage/>);
|
||||
|
||||
@ -88,14 +75,14 @@ describe('<HomePage/>', function () {
|
||||
|
||||
it('test no backend connection behaviour', done => {
|
||||
// this test assumes a console.log within every connection fail
|
||||
global.fetch = prepareFailingFetchApi();
|
||||
global.fetch = global.prepareFailingFetchApi();
|
||||
|
||||
let count = 0;
|
||||
global.console.log = jest.fn((m) => {
|
||||
global.console.log = jest.fn(() => {
|
||||
count++;
|
||||
});
|
||||
|
||||
const wrapper = shallow(<HomePage/>);
|
||||
shallow(<HomePage/>);
|
||||
|
||||
process.nextTick(() => {
|
||||
// state to be set correctly with response
|
||||
|
Reference in New Issue
Block a user