fix Overview tests

This commit is contained in:
2020-10-14 21:30:32 +03:00
committed by Stepan Usatiuk
parent ca67ff3496
commit e1411b1c1f
2 changed files with 9 additions and 4 deletions

View File

@@ -33,7 +33,6 @@ export const OverviewComponent: React.FunctionComponent<IOverviewComponentProps>
return (
<div id="overview">
{" "}
<div className="list">{photos}</div>
</div>
);

View File

@@ -7,20 +7,26 @@ afterEach(() => {
jest.restoreAllMocks();
});
const fetchPhotosFn = jest.fn();
const overviewComponentDefaultProps: IOverviewComponentProps = {
photos: null,
fetching: false,
fetchingError: null,
fetchingSpinner: false,
fetchPhotos: jest.fn(),
fetchPhotos: fetchPhotosFn,
};
describe("<Overview />", () => {
it("should not crash", () => {
afterEach(() => {
jest.clearAllMocks();
});
it("should not crash and call fetchPhotos", () => {
const wrapper = shallow(
<OverviewComponent {...overviewComponentDefaultProps} />,
);
expect(wrapper.contains("Overview!")).toBeTruthy();
expect(fetchPhotosFn).toHaveBeenCalled();
});
});