correct sort order of css properties
mocking of fetch api only once in setupTests
This commit is contained in:
@ -2,14 +2,6 @@ import {mount, shallow} from "enzyme";
|
||||
import React from "react";
|
||||
import CategoryPage from "./CategoryPage";
|
||||
|
||||
function prepareFetchApi(response) {
|
||||
const mockJsonPromise = Promise.resolve(response);
|
||||
const mockFetchPromise = Promise.resolve({
|
||||
json: () => mockJsonPromise,
|
||||
});
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
|
||||
describe('<CategoryPage/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<CategoryPage/>);
|
||||
@ -17,7 +9,7 @@ describe('<CategoryPage/>', function () {
|
||||
});
|
||||
|
||||
it('test tag fetch call', done => {
|
||||
global.fetch = prepareFetchApi(["first", "second"]);
|
||||
global.fetch = global.prepareFetchApi(["first", "second"]);
|
||||
|
||||
const wrapper = shallow(<CategoryPage/>);
|
||||
|
||||
@ -33,14 +25,14 @@ describe('<CategoryPage/>', function () {
|
||||
});
|
||||
|
||||
it('test errored fetch call', done => {
|
||||
global.fetch = prepareFetchApi({});
|
||||
global.fetch = global.prepareFetchApi({});
|
||||
|
||||
let message;
|
||||
global.console.log = jest.fn((m) => {
|
||||
message = m;
|
||||
});
|
||||
|
||||
const wrapper = shallow(<CategoryPage/>);
|
||||
shallow(<CategoryPage/>);
|
||||
|
||||
expect(global.fetch).toHaveBeenCalledTimes(1);
|
||||
|
||||
@ -67,7 +59,7 @@ describe('<CategoryPage/>', function () {
|
||||
});
|
||||
|
||||
it('test setpage callback', done => {
|
||||
global.fetch = prepareFetchApi([{}, {}]);
|
||||
global.fetch = global.prepareFetchApi([{}, {}]);
|
||||
|
||||
const wrapper = mount(<CategoryPage/>);
|
||||
|
||||
@ -106,7 +98,7 @@ describe('<CategoryPage/>', function () {
|
||||
const func = jest.fn();
|
||||
CategoryPage.prototype.fetchVideoData = func;
|
||||
|
||||
const wrapper = shallow(<CategoryPage category="fullhd"/>);
|
||||
shallow(<CategoryPage category="fullhd"/>);
|
||||
|
||||
expect(func).toBeCalledTimes(1);
|
||||
});
|
||||
|
@ -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
|
||||
|
@ -1,28 +1,13 @@
|
||||
import React from "react";
|
||||
import style from "./Player.module.css"
|
||||
import {PlyrComponent} from 'plyr-react';
|
||||
import SideBar, {SideBarTitle, SideBarItem} from "../../elements/SideBar/SideBar";
|
||||
import SideBar, {SideBarItem, SideBarTitle} from "../../elements/SideBar/SideBar";
|
||||
import Tag from "../../elements/Tag/Tag";
|
||||
import AddTagPopup from "../../elements/AddTagPopup/AddTagPopup";
|
||||
import PageTitle from "../../elements/PageTitle/PageTitle";
|
||||
|
||||
|
||||
class Player extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
|
||||
this.state = {
|
||||
sources: null,
|
||||
movie_id: null,
|
||||
movie_name: null,
|
||||
likes: null,
|
||||
quality: null,
|
||||
length: null,
|
||||
tags: [],
|
||||
popupvisible: false
|
||||
};
|
||||
}
|
||||
|
||||
options = {
|
||||
controls: [
|
||||
'play-large', // The large play button in the center
|
||||
@ -40,6 +25,21 @@ class Player extends React.Component {
|
||||
]
|
||||
};
|
||||
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
|
||||
this.state = {
|
||||
sources: null,
|
||||
movie_id: null,
|
||||
movie_name: null,
|
||||
likes: null,
|
||||
quality: null,
|
||||
length: null,
|
||||
tags: [],
|
||||
popupvisible: false
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchMovieData();
|
||||
}
|
||||
@ -58,7 +58,8 @@ class Player extends React.Component {
|
||||
{this.state.quality !== 0 ?
|
||||
<SideBarItem><b>{this.state.quality}p</b> Quality!</SideBarItem> : null}
|
||||
{this.state.length !== 0 ?
|
||||
<SideBarItem><b>{Math.round(this.state.length / 60)}</b> Minutes of length!</SideBarItem>: null}
|
||||
<SideBarItem><b>{Math.round(this.state.length / 60)}</b> Minutes of
|
||||
length!</SideBarItem> : null}
|
||||
<hr/>
|
||||
<SideBarTitle>Tags:</SideBarTitle>
|
||||
{this.state.tags.map((m) => (
|
||||
|
@ -1,19 +1,19 @@
|
||||
.closebutton {
|
||||
color: white;
|
||||
background-color: #FF0000;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
padding: 5px 15px 5px 15px;
|
||||
background-color: #FF0000;
|
||||
margin-top: 25px;
|
||||
color: white;
|
||||
margin-left: 25px;
|
||||
margin-top: 25px;
|
||||
padding: 5px 15px 5px 15px;
|
||||
}
|
||||
|
||||
.videowrapper {
|
||||
margin-left: 20px;
|
||||
display: block;
|
||||
float: left;
|
||||
width: 60%;
|
||||
margin-left: 20px;
|
||||
margin-top: 25px;
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.videoactions {
|
||||
|
@ -2,14 +2,6 @@ import {shallow} from "enzyme";
|
||||
import React from "react";
|
||||
import Player from "./Player";
|
||||
|
||||
function prepareFetchApi(response) {
|
||||
const mockJsonPromise = Promise.resolve(response);
|
||||
const mockFetchPromise = Promise.resolve({
|
||||
json: () => mockJsonPromise,
|
||||
});
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
|
||||
describe('<Player/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<Player/>);
|
||||
@ -32,7 +24,7 @@ describe('<Player/>', function () {
|
||||
});
|
||||
|
||||
it('likebtn click', done => {
|
||||
global.fetch = prepareFetchApi({result: 'success'});
|
||||
global.fetch = global.prepareFetchApi({result: 'success'});
|
||||
|
||||
const func = jest.fn();
|
||||
|
||||
@ -59,7 +51,7 @@ describe('<Player/>', function () {
|
||||
});
|
||||
|
||||
it('errored likebtn click', done => {
|
||||
global.fetch = prepareFetchApi({result: 'nosuccess'});
|
||||
global.fetch = global.prepareFetchApi({result: 'nosuccess'});
|
||||
const func = jest.fn();
|
||||
|
||||
const wrapper = shallow(<Player/>);
|
||||
|
@ -1,19 +1,19 @@
|
||||
.Shufflebutton {
|
||||
width: 100%;
|
||||
align-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.btnshuffle {
|
||||
background-color: #39a945;
|
||||
|
||||
color: white;
|
||||
margin-top: 20px;
|
||||
margin-left: 45%;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
padding: 15px 25px 15px 25px;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
font-size: larger;
|
||||
font-weight: bold;
|
||||
margin-left: 45%;
|
||||
margin-top: 20px;
|
||||
padding: 15px 25px 15px 25px;
|
||||
}
|
||||
|
||||
.btnshuffle:focus {
|
||||
|
@ -2,14 +2,6 @@ import {shallow} from "enzyme";
|
||||
import React from "react";
|
||||
import RandomPage from "./RandomPage";
|
||||
|
||||
function prepareFetchApi(response) {
|
||||
const mockJsonPromise = Promise.resolve(response);
|
||||
const mockFetchPromise = Promise.resolve({
|
||||
json: () => mockJsonPromise,
|
||||
});
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
|
||||
describe('<RandomPage/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<RandomPage/>);
|
||||
@ -17,22 +9,24 @@ describe('<RandomPage/>', function () {
|
||||
});
|
||||
|
||||
it('test shuffleload fetch', function () {
|
||||
global.fetch = prepareFetchApi({});
|
||||
global.fetch = global.prepareFetchApi({});
|
||||
|
||||
const wrapper = shallow(<RandomPage/>);
|
||||
shallow(<RandomPage/>);
|
||||
|
||||
expect(global.fetch).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('btnshuffle click test', function () {
|
||||
global.fetch = prepareFetchApi({});
|
||||
global.fetch = global.prepareFetchApi({});
|
||||
|
||||
const wrapper = shallow(<RandomPage/>);
|
||||
|
||||
// simulate at least one existing element
|
||||
wrapper.setState({videos: [
|
||||
wrapper.setState({
|
||||
videos: [
|
||||
{}
|
||||
]});
|
||||
]
|
||||
});
|
||||
|
||||
wrapper.find(".btnshuffle").simulate("click");
|
||||
|
||||
|
@ -2,14 +2,6 @@ import {shallow} from "enzyme";
|
||||
import React from "react";
|
||||
import GeneralSettings from "./GeneralSettings";
|
||||
|
||||
function prepareFetchApi(response) {
|
||||
const mockJsonPromise = Promise.resolve(response);
|
||||
const mockFetchPromise = Promise.resolve({
|
||||
json: () => mockJsonPromise,
|
||||
});
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
|
||||
describe('<GeneralSettings/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<GeneralSettings/>);
|
||||
@ -28,7 +20,7 @@ describe('<GeneralSettings/>', function () {
|
||||
it('test savesettings', done => {
|
||||
const wrapper = shallow(<GeneralSettings/>);
|
||||
|
||||
global.fetch = prepareFetchApi({success: true});
|
||||
global.fetch = global.prepareFetchApi({success: true});
|
||||
|
||||
expect(global.fetch).toBeCalledTimes(0);
|
||||
const fakeEvent = {preventDefault: () => console.log('preventDefault')};
|
||||
@ -46,7 +38,7 @@ describe('<GeneralSettings/>', function () {
|
||||
it('test failing savesettings', done => {
|
||||
const wrapper = shallow(<GeneralSettings/>);
|
||||
|
||||
global.fetch = prepareFetchApi({success: false});
|
||||
global.fetch = global.prepareFetchApi({success: false});
|
||||
|
||||
expect(global.fetch).toBeCalledTimes(0);
|
||||
const fakeEvent = {preventDefault: () => console.log('preventDefault')};
|
||||
|
@ -1,13 +1,13 @@
|
||||
.indextextarea {
|
||||
margin-top: 15px;
|
||||
padding: 10px;
|
||||
|
||||
overflow-y: scroll;
|
||||
overflow-x: auto;
|
||||
|
||||
min-height: 100px;
|
||||
max-height: 300px;
|
||||
width: 50%;
|
||||
background-color: #c2c2c2;
|
||||
border-radius: 5px;
|
||||
|
||||
margin-top: 15px;
|
||||
max-height: 300px;
|
||||
|
||||
min-height: 100px;
|
||||
overflow-x: auto;
|
||||
overflow-y: scroll;
|
||||
padding: 10px;
|
||||
width: 50%;
|
||||
}
|
||||
|
@ -2,14 +2,6 @@ import {shallow} from "enzyme";
|
||||
import React from "react";
|
||||
import MovieSettings from "./MovieSettings";
|
||||
|
||||
function prepareFetchApi(response) {
|
||||
const mockJsonPromise = Promise.resolve(response);
|
||||
const mockFetchPromise = Promise.resolve({
|
||||
json: () => mockJsonPromise,
|
||||
});
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
|
||||
describe('<MovieSettings/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<MovieSettings/>);
|
||||
@ -30,7 +22,7 @@ describe('<MovieSettings/>', function () {
|
||||
});
|
||||
|
||||
it('test simulate reindex', function () {
|
||||
global.fetch = prepareFetchApi({});
|
||||
global.fetch = global.prepareFetchApi({});
|
||||
const wrapper = shallow(<MovieSettings/>);
|
||||
|
||||
wrapper.find(".reindexbtn").simulate("click");
|
||||
@ -40,7 +32,7 @@ describe('<MovieSettings/>', function () {
|
||||
});
|
||||
|
||||
it('content available received and in state', done => {
|
||||
global.fetch = prepareFetchApi({
|
||||
global.fetch = global.prepareFetchApi({
|
||||
contentAvailable: true,
|
||||
message: "firstline\nsecondline"
|
||||
});
|
||||
|
@ -1,40 +1,40 @@
|
||||
.SettingsSidebar {
|
||||
padding-top: 20px;
|
||||
float: left;
|
||||
width: 10%;
|
||||
background-color: #d3dcef;
|
||||
float: left;
|
||||
min-height: calc(100vh - 56px);
|
||||
min-width: 110px;
|
||||
padding-top: 20px;
|
||||
width: 10%;
|
||||
}
|
||||
|
||||
.SettingsSidebarTitle {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
font-size: larger;
|
||||
font-weight: bold;
|
||||
margin-bottom: 25px;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.SettingsContent {
|
||||
float: left;
|
||||
width: 80%;
|
||||
padding-left: 30px;
|
||||
padding-top: 30px;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.SettingSidebarElement {
|
||||
background-color: #a8b2de;
|
||||
border-radius: 7px;
|
||||
font-weight: bold;
|
||||
margin: 10px 5px 5px;
|
||||
padding: 5px;
|
||||
background-color: #a8b2de;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
border-radius: 7px;
|
||||
}
|
||||
|
||||
.SettingSidebarElement:hover {
|
||||
font-weight: bolder;
|
||||
background-color: #7d8dd4;
|
||||
box-shadow: #7d8dd4 0 0 0 5px;
|
||||
transition: all 300ms;
|
||||
cursor: pointer;
|
||||
}
|
||||
font-weight: bolder;
|
||||
transition: all 300ms;
|
||||
}
|
||||
|
@ -2,14 +2,6 @@ import {shallow} from "enzyme";
|
||||
import React from "react";
|
||||
import SettingsPage from "./SettingsPage";
|
||||
|
||||
function prepareFetchApi(response) {
|
||||
const mockJsonPromise = Promise.resolve(response);
|
||||
const mockFetchPromise = Promise.resolve({
|
||||
json: () => mockJsonPromise,
|
||||
});
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
|
||||
describe('<RandomPage/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<SettingsPage/>);
|
||||
|
Reference in New Issue
Block a user