Tests for all Components
This commit is contained in:
41
src/pages/SettingsPage/SettingsPage.test.js
Normal file
41
src/pages/SettingsPage/SettingsPage.test.js
Normal file
@ -0,0 +1,41 @@
|
||||
import {shallow} from "enzyme";
|
||||
import React from "react";
|
||||
import SettingsPage from "./SettingsPage";
|
||||
|
||||
function prepareFetchApi(response) {
|
||||
const mockJsonPromise = Promise.resolve(response);
|
||||
const mockFetchPromise = Promise.resolve({
|
||||
json: () => mockJsonPromise,
|
||||
});
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
|
||||
describe('<RandomPage/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<SettingsPage/>);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('received text renders into dom', function () {
|
||||
const wrapper = shallow(<SettingsPage/>);
|
||||
|
||||
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(<SettingsPage/>);
|
||||
|
||||
wrapper.find(".reindexbtn").simulate("click");
|
||||
|
||||
// initial send of reindex request to server
|
||||
expect(global.fetch).toBeCalledTimes(1);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user