diff --git a/src/Components/Profile/Subcomponents/GalleryForm.spec.tsx b/src/Components/Profile/Subcomponents/GalleryForm.spec.tsx index dd8d2713..03be6427 100644 --- a/src/Components/Profile/Subcomponents/GalleryForm.spec.tsx +++ b/src/Components/Profile/Subcomponents/GalleryForm.spec.tsx @@ -83,11 +83,17 @@ describe('GalleryForm', () => { expect(wrapper.container).toMatchSnapshot() }) - it('can delete an image', () => { + it('can open and close delete modal', () => { Wrapper({ gallery }) - const deleteButton = screen.getByTestId('delete-image-1') + const deleteButton = screen.getAllByTestId('trash')[0] expect(deleteButton).toBeInTheDocument() fireEvent.click(deleteButton) + const confirmationText = screen.getByText('Do you want to delete this image?') + expect(confirmationText).toBeInTheDocument() + const confirmButton = screen.getByText('Yes') + expect(confirmButton).toBeInTheDocument() + fireEvent.click(confirmButton) + expect(confirmationText).not.toBeInTheDocument() }) }) diff --git a/src/Components/Profile/Subcomponents/GalleryForm.tsx b/src/Components/Profile/Subcomponents/GalleryForm.tsx index 82c2449d..f808450f 100644 --- a/src/Components/Profile/Subcomponents/GalleryForm.tsx +++ b/src/Components/Profile/Subcomponents/GalleryForm.tsx @@ -111,7 +111,7 @@ export const GalleryForm = ({ state, setState }: Props) => { onClick={() => setImageSelectedToDelete(index)} type='button' > - + )} diff --git a/src/Components/Profile/Subcomponents/__snapshots__/GalleryForm.spec.tsx.snap b/src/Components/Profile/Subcomponents/__snapshots__/GalleryForm.spec.tsx.snap index 1b194110..a252a173 100644 --- a/src/Components/Profile/Subcomponents/__snapshots__/GalleryForm.spec.tsx.snap +++ b/src/Components/Profile/Subcomponents/__snapshots__/GalleryForm.spec.tsx.snap @@ -3,24 +3,25 @@ exports[`GalleryForm > with previous images > renders 1`] = `
Gallery image 1
@@ -98,15 +105,15 @@ exports[`GalleryForm > with previous images > renders 1`] = ` exports[`GalleryForm > with uploading images > renders 1`] = `
Gallery image 1 with uploading images > renders 1`] = ` > Gallery image 2 with uploading images > renders 1`] = ` > Gallery image 3
@@ -173,10 +185,10 @@ exports[`GalleryForm > with uploading images > renders 1`] = ` exports[`GalleryForm > without previous images > renders 1`] = `