From 0cc1b3a41b7012f62da5477423abb11435543de8 Mon Sep 17 00:00:00 2001 From: Anikesh Suresh Date: Tue, 14 Jan 2025 13:11:24 +0000 Subject: [PATCH] fix linting and unit tests #1075 --- src/common/editFileDialog.component.test.tsx | 2 +- src/common/editFileDialog.component.tsx | 4 ++-- src/mocks/handlers.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/editFileDialog.component.test.tsx b/src/common/editFileDialog.component.test.tsx index abe94d589..b119dd77f 100644 --- a/src/common/editFileDialog.component.test.tsx +++ b/src/common/editFileDialog.component.test.tsx @@ -98,7 +98,7 @@ describe('Edit file dialog', () => { await user.click(saveButton); expect(axiosPatchSpy).toHaveBeenCalledWith('/images/1', { - file_name: 'test_file_name.jpeg', + file_name: 'test_file_name.jpeg.png', title: 'Test Title', description: 'Test Description', }); diff --git a/src/common/editFileDialog.component.tsx b/src/common/editFileDialog.component.tsx index 965853863..4b0e58026 100644 --- a/src/common/editFileDialog.component.tsx +++ b/src/common/editFileDialog.component.tsx @@ -53,7 +53,7 @@ const EditFileDialog = (props: FileDialogProps) => { const selectedFileCopy: ObjectFilePatch = React.useMemo( () => (selectedFile ? { ...selectedFile, file_name: initialName } : {}), - [selectedFile] + [selectedFile, initialName] ); const initialFile: ObjectFilePatch = React.useMemo( @@ -109,7 +109,7 @@ const EditFileDialog = (props: FileDialogProps) => { const isTitleUpdated = fileData.title !== selectedFileCopy.title; - let fileToEdit: ObjectFilePatch = {}; + const fileToEdit: ObjectFilePatch = {}; if (isFileNameUpdated) fileToEdit.file_name = fileData.file_name + extension; diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts index eafacac1c..744da8284 100644 --- a/src/mocks/handlers.ts +++ b/src/mocks/handlers.ts @@ -1084,7 +1084,7 @@ export const handlers = [ const fullBody = { ...obj, ...body }; - if (fullBody.file_name === 'Error 500') { + if (fullBody.file_name === 'Error 500.png') { return HttpResponse.json( { detail: 'Something went wrong' }, { status: 500 }