diff --git a/src/elements/VideoContainer/VideoContainer.js b/src/elements/VideoContainer/VideoContainer.js index 49b820c..ac95277 100644 --- a/src/elements/VideoContainer/VideoContainer.js +++ b/src/elements/VideoContainer/VideoContainer.js @@ -36,6 +36,7 @@ class VideoContainer extends React.Component { {/*todo css for no items to show*/} {this.state.loadeditems.length === 0 ? "no items to show!" : null} + {this.props.children} ); } diff --git a/src/pages/RandomPage/RandomPage.js b/src/pages/RandomPage/RandomPage.js index 9420dad..085633a 100644 --- a/src/pages/RandomPage/RandomPage.js +++ b/src/pages/RandomPage/RandomPage.js @@ -1,9 +1,9 @@ import React from "react"; -import Preview from "../../elements/Preview/Preview"; import style from "./RandomPage.module.css" import SideBar, {SideBarTitle} from "../../elements/SideBar/SideBar"; import Tag from "../../elements/Tag/Tag"; import PageTitle from "../../elements/PageTitle/PageTitle"; +import VideoContainer from "../../elements/VideoContainer/VideoContainer"; class RandomPage extends React.Component { constructor(props, context) { @@ -35,18 +35,17 @@ class RandomPage extends React.Component { ))} -
- {this.state.videos.map(elem => ( - - ))} -
- -
-
+ {this.state.videos.length !== 0 ? + +
+ +
+
+ : +
No Data found!
} + ); } @@ -65,6 +64,8 @@ class RandomPage extends React.Component { .then((response) => response.json() .then((result) => { console.log(result); + + this.setState({videos: []}); // needed to trigger rerender of main videoview this.setState({ videos: result.rows, tags: result.tags diff --git a/src/pages/RandomPage/RandomPage.test.js b/src/pages/RandomPage/RandomPage.test.js index a0d2624..beeeeca 100644 --- a/src/pages/RandomPage/RandomPage.test.js +++ b/src/pages/RandomPage/RandomPage.test.js @@ -29,6 +29,11 @@ describe('', function () { const wrapper = shallow(); + // simulate at least one existing element + wrapper.setState({videos: [ + {} + ]}); + wrapper.find(".btnshuffle").simulate("click"); expect(global.fetch).toBeCalledTimes(2);