added some tests and rounder buttons of settings items
This commit is contained in:
		@@ -16,5 +16,47 @@ describe('<MovieSettings/>', function () {
 | 
				
			|||||||
        wrapper.unmount();
 | 
					        wrapper.unmount();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('received text renders into dom', function () {
 | 
				
			||||||
 | 
					        const wrapper = shallow(<MovieSettings/>);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        wrapper.setState({
 | 
				
			||||||
 | 
					            text: [
 | 
				
			||||||
 | 
					                "firstline",
 | 
				
			||||||
 | 
					                "secline"
 | 
				
			||||||
 | 
					            ]
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        expect(wrapper.find(".indextextarea").find(".textarea-element")).toHaveLength(2);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('test simulate reindex', function () {
 | 
				
			||||||
 | 
					        global.fetch = prepareFetchApi({});
 | 
				
			||||||
 | 
					        const wrapper = shallow(<MovieSettings/>);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        wrapper.find(".reindexbtn").simulate("click");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // initial send of reindex request to server
 | 
				
			||||||
 | 
					        expect(global.fetch).toBeCalledTimes(1);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('content available received and in state', done => {
 | 
				
			||||||
 | 
					        global.fetch = prepareFetchApi({
 | 
				
			||||||
 | 
					            contentAvailable: true,
 | 
				
			||||||
 | 
					            message: "firstline\nsecondline"
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        const wrapper = shallow(<MovieSettings/>);
 | 
				
			||||||
 | 
					        wrapper.instance().updateStatus();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        process.nextTick(() => {
 | 
				
			||||||
 | 
					            expect(wrapper.state()).toMatchObject({
 | 
				
			||||||
 | 
					                text: [
 | 
				
			||||||
 | 
					                    "firstline",
 | 
				
			||||||
 | 
					                    "secondline"
 | 
				
			||||||
 | 
					                ]
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            global.fetch.mockClear();
 | 
				
			||||||
 | 
					            done();
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@
 | 
				
			|||||||
    background-color: #a8b2de;
 | 
					    background-color: #a8b2de;
 | 
				
			||||||
    text-align: center;
 | 
					    text-align: center;
 | 
				
			||||||
    font-weight: bold;
 | 
					    font-weight: bold;
 | 
				
			||||||
 | 
					    border-radius: 7px;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.SettingSidebarElement:hover {
 | 
					.SettingSidebarElement:hover {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,8 @@ class SettingsPage extends React.Component {
 | 
				
			|||||||
                return <GeneralSettings/>;
 | 
					                return <GeneralSettings/>;
 | 
				
			||||||
            case "movies":
 | 
					            case "movies":
 | 
				
			||||||
                return <MovieSettings/>;
 | 
					                return <MovieSettings/>;
 | 
				
			||||||
 | 
					            case "tv":
 | 
				
			||||||
 | 
					                return <a/>; // todo this page
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                return "unknown button clicked";
 | 
					                return "unknown button clicked";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,26 +16,33 @@ describe('<RandomPage/>', function () {
 | 
				
			|||||||
        wrapper.unmount();
 | 
					        wrapper.unmount();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it('received text renders into dom', function () {
 | 
					    it('simulate topic clicka', function () {
 | 
				
			||||||
        const wrapper = shallow(<SettingsPage/>);
 | 
					        const wrapper = shallow(<SettingsPage/>);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        wrapper.setState({
 | 
					        simulateSideBarClick("General",wrapper);
 | 
				
			||||||
            text: [
 | 
					        expect(wrapper.state().currentpage).toBe("general");
 | 
				
			||||||
                "firstline",
 | 
					        expect(wrapper.find(".SettingsContent").find("GeneralSettings")).toHaveLength(1);
 | 
				
			||||||
                "secline"
 | 
					 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        expect(wrapper.find(".indextextarea").find(".textarea-element")).toHaveLength(2);
 | 
					        simulateSideBarClick("Movies",wrapper);
 | 
				
			||||||
 | 
					        expect(wrapper.state().currentpage).toBe("movies");
 | 
				
			||||||
 | 
					        expect(wrapper.find(".SettingsContent").find("MovieSettings")).toHaveLength(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        simulateSideBarClick("TV Shows",wrapper);
 | 
				
			||||||
 | 
					        expect(wrapper.state().currentpage).toBe("tv");
 | 
				
			||||||
 | 
					        expect(wrapper.find(".SettingsContent").find("a")).toHaveLength(1);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it('test simulate reindex', function () {
 | 
					    function simulateSideBarClick(name, wrapper) {
 | 
				
			||||||
        global.fetch = prepareFetchApi({});
 | 
					        wrapper.find(".SettingSidebarElement").findWhere(it =>
 | 
				
			||||||
 | 
					            it.text() === name &&
 | 
				
			||||||
 | 
					            it.type() === "div").simulate("click");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('simulate unknown topic', function () {
 | 
				
			||||||
        const wrapper = shallow(<SettingsPage/>);
 | 
					        const wrapper = shallow(<SettingsPage/>);
 | 
				
			||||||
 | 
					        wrapper.setState({currentpage: "unknown"});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        wrapper.find(".reindexbtn").simulate("click");
 | 
					        expect(wrapper.find(".SettingsContent").text()).toBe("unknown button clicked");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // initial send of reindex request to server
 | 
					 | 
				
			||||||
        expect(global.fetch).toBeCalledTimes(1);
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user