From 48aab3f160571dbe5ed3d9ebc2c9a11da6307c42 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Mon, 2 May 2022 22:09:35 +0200 Subject: [PATCH] fix tests --- frontend/src/Photos/Photo.tsx | 13 ++----------- frontend/src/Photos/tests/Overview.test.tsx | 5 +++++ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/frontend/src/Photos/Photo.tsx b/frontend/src/Photos/Photo.tsx index bfd5606..f2d7c27 100644 --- a/frontend/src/Photos/Photo.tsx +++ b/frontend/src/Photos/Photo.tsx @@ -120,18 +120,9 @@ export const PhotoComponent: React.FunctionComponent = ( function mapStateToProps(state: IAppState, props: IPhotoComponentProps) { const { id } = props; - let photo = undefined; - let photoState = undefined; - - if (state.photos.photos) { - photo = state.photos.photos.find((p) => p.id === id); - } - if (state.photos.photoStates[id]) { - photoState = state.photos.photoStates[id]; - } return { - photo, - photoState, + photo: state.photos?.photos?.find((p) => p.id === id), + photoState: state.photos?.photoStates?.[id], }; } diff --git a/frontend/src/Photos/tests/Overview.test.tsx b/frontend/src/Photos/tests/Overview.test.tsx index 325c62d..9879a5b 100644 --- a/frontend/src/Photos/tests/Overview.test.tsx +++ b/frontend/src/Photos/tests/Overview.test.tsx @@ -8,6 +8,8 @@ afterEach(() => { }); const fetchPhotosFn = jest.fn(); +const startDeletePhotosFn = jest.fn(); +const cancelDeleteFn = jest.fn(); const overviewComponentDefaultProps: IOverviewComponentProps = { photos: [], @@ -16,8 +18,11 @@ const overviewComponentDefaultProps: IOverviewComponentProps = { overviewFetching: false, overviewFetchingError: null, overviewFetchingSpinner: false, + darkMode: false, fetchPhotos: fetchPhotosFn, + startDeletePhotos: startDeletePhotosFn, + cancelDelete: cancelDeleteFn, }; describe("", () => {