OpenMediaCenter/src/pages/RandomPage/RandomPage.test.js
Lukas Heiligenbrunner f80554bfdd correct sort order of css properties
mocking of fetch api only once in setupTests
2020-08-05 17:55:51 +00:00

49 lines
1.2 KiB
JavaScript

import {shallow} from "enzyme";
import React from "react";
import RandomPage from "./RandomPage";
describe('<RandomPage/>', function () {
it('renders without crashing ', function () {
const wrapper = shallow(<RandomPage/>);
wrapper.unmount();
});
it('test shuffleload fetch', function () {
global.fetch = global.prepareFetchApi({});
shallow(<RandomPage/>);
expect(global.fetch).toBeCalledTimes(1);
});
it('btnshuffle click test', function () {
global.fetch = global.prepareFetchApi({});
const wrapper = shallow(<RandomPage/>);
// simulate at least one existing element
wrapper.setState({
videos: [
{}
]
});
wrapper.find(".btnshuffle").simulate("click");
expect(global.fetch).toBeCalledTimes(2);
});
it('test tags in random selection', function () {
const wrapper = shallow(<RandomPage/>);
wrapper.setState({
tags: [
{tag_name: "test1"},
{tag_name: "test2"}
]
});
expect(wrapper.find("Tag")).toHaveLength(2);
});
});