OpenMediaCenter/src/pages/RandomPage/RandomPage.test.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-06-12 15:57:30 +00:00
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({});
2020-06-12 15:57:30 +00:00
shallow(<RandomPage/>);
2020-06-12 15:57:30 +00:00
expect(global.fetch).toBeCalledTimes(1);
});
it('btnshuffle click test', function () {
global.fetch = global.prepareFetchApi({});
2020-06-12 15:57:30 +00:00
const wrapper = shallow(<RandomPage/>);
// simulate at least one existing element
wrapper.setState({
videos: [
{}
]
});
2020-06-12 15:57:30 +00:00
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);
});
});