2020-06-12 15:57:30 +00:00
|
|
|
import {shallow} from "enzyme";
|
|
|
|
import React from "react";
|
|
|
|
import SettingsPage from "./SettingsPage";
|
|
|
|
|
|
|
|
describe('<RandomPage/>', function () {
|
|
|
|
it('renders without crashing ', function () {
|
|
|
|
const wrapper = shallow(<SettingsPage/>);
|
|
|
|
wrapper.unmount();
|
|
|
|
});
|
|
|
|
|
2020-06-29 19:55:40 +02:00
|
|
|
it('simulate topic clicka', function () {
|
2020-06-12 15:57:30 +00:00
|
|
|
const wrapper = shallow(<SettingsPage/>);
|
|
|
|
|
2020-07-13 00:44:16 +02:00
|
|
|
simulateSideBarClick("General", wrapper);
|
2020-06-29 19:55:40 +02:00
|
|
|
expect(wrapper.state().currentpage).toBe("general");
|
|
|
|
expect(wrapper.find(".SettingsContent").find("GeneralSettings")).toHaveLength(1);
|
2020-06-12 15:57:30 +00:00
|
|
|
|
2020-07-13 00:44:16 +02:00
|
|
|
simulateSideBarClick("Movies", wrapper);
|
2020-06-29 19:55:40 +02:00
|
|
|
expect(wrapper.state().currentpage).toBe("movies");
|
|
|
|
expect(wrapper.find(".SettingsContent").find("MovieSettings")).toHaveLength(1);
|
|
|
|
|
2020-07-13 00:44:16 +02:00
|
|
|
simulateSideBarClick("TV Shows", wrapper);
|
2020-06-29 19:55:40 +02:00
|
|
|
expect(wrapper.state().currentpage).toBe("tv");
|
2020-06-29 21:34:43 +02:00
|
|
|
expect(wrapper.find(".SettingsContent").find("span")).toHaveLength(1);
|
2020-06-12 15:57:30 +00:00
|
|
|
});
|
|
|
|
|
2020-06-29 19:55:40 +02:00
|
|
|
function simulateSideBarClick(name, wrapper) {
|
|
|
|
wrapper.find(".SettingSidebarElement").findWhere(it =>
|
|
|
|
it.text() === name &&
|
|
|
|
it.type() === "div").simulate("click");
|
|
|
|
}
|
|
|
|
|
|
|
|
it('simulate unknown topic', function () {
|
2020-06-12 15:57:30 +00:00
|
|
|
const wrapper = shallow(<SettingsPage/>);
|
2020-06-29 19:55:40 +02:00
|
|
|
wrapper.setState({currentpage: "unknown"});
|
2020-06-12 15:57:30 +00:00
|
|
|
|
2020-06-29 19:55:40 +02:00
|
|
|
expect(wrapper.find(".SettingsContent").text()).toBe("unknown button clicked");
|
2020-06-12 15:57:30 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
});
|