mirror of
https://github.com/usatiuk/photos.git
synced 2025-10-28 23:37:48 +01:00
fix Overview tests
This commit is contained in:
@@ -33,7 +33,6 @@ export const OverviewComponent: React.FunctionComponent<IOverviewComponentProps>
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="overview">
|
<div id="overview">
|
||||||
{" "}
|
|
||||||
<div className="list">{photos}</div>
|
<div className="list">{photos}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,20 +7,26 @@ afterEach(() => {
|
|||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const fetchPhotosFn = jest.fn();
|
||||||
|
|
||||||
const overviewComponentDefaultProps: IOverviewComponentProps = {
|
const overviewComponentDefaultProps: IOverviewComponentProps = {
|
||||||
photos: null,
|
photos: null,
|
||||||
fetching: false,
|
fetching: false,
|
||||||
fetchingError: null,
|
fetchingError: null,
|
||||||
fetchingSpinner: false,
|
fetchingSpinner: false,
|
||||||
|
|
||||||
fetchPhotos: jest.fn(),
|
fetchPhotos: fetchPhotosFn,
|
||||||
};
|
};
|
||||||
|
|
||||||
describe("<Overview />", () => {
|
describe("<Overview />", () => {
|
||||||
it("should not crash", () => {
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not crash and call fetchPhotos", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<OverviewComponent {...overviewComponentDefaultProps} />,
|
<OverviewComponent {...overviewComponentDefaultProps} />,
|
||||||
);
|
);
|
||||||
expect(wrapper.contains("Overview!")).toBeTruthy();
|
expect(fetchPhotosFn).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user