From b7017e28574a36cb7fd6c5ac5632958ddfabcb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Mon, 13 Nov 2023 21:02:19 +0000 Subject: [PATCH] chore: file_type -> fileType --- api.planx.uk/modules/file/controller.ts | 3 +-- api.planx.uk/modules/file/file.test.ts | 4 ++-- .../modules/file/service/uploadFile.ts | 4 ++-- .../FileUploadAndLabel/Public.test.tsx | 20 +++++++++---------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/api.planx.uk/modules/file/controller.ts b/api.planx.uk/modules/file/controller.ts index a63b03b621..ba77a1a26e 100644 --- a/api.planx.uk/modules/file/controller.ts +++ b/api.planx.uk/modules/file/controller.ts @@ -13,8 +13,7 @@ assert(process.env.AWS_ACCESS_KEY); assert(process.env.AWS_SECRET_KEY); interface UploadFileResponse { - // TODO: change to snake case - file_type: string | null; + fileType: string | null; fileUrl: string; } diff --git a/api.planx.uk/modules/file/file.test.ts b/api.planx.uk/modules/file/file.test.ts index 6824871102..084ba3ad33 100644 --- a/api.planx.uk/modules/file/file.test.ts +++ b/api.planx.uk/modules/file/file.test.ts @@ -74,7 +74,7 @@ describe("File upload", () => { .attach("file", Buffer.from("some data"), "some_file.txt") .then((res) => { expect(res.body).toEqual({ - file_type: "text/plain", + fileType: "text/plain", fileUrl: expect.stringContaining( "/file/private/nanoid/modified%20key", ), @@ -135,7 +135,7 @@ describe("File upload", () => { .attach("file", Buffer.from("some data"), "some_file.txt") .then((res) => { expect(res.body).toEqual({ - file_type: "text/plain", + fileType: "text/plain", fileUrl: expect.stringContaining( "file/public/nanoid/modified%20key", ), diff --git a/api.planx.uk/modules/file/service/uploadFile.ts b/api.planx.uk/modules/file/service/uploadFile.ts index 856eae425c..f1ec699c82 100644 --- a/api.planx.uk/modules/file/service/uploadFile.ts +++ b/api.planx.uk/modules/file/service/uploadFile.ts @@ -17,7 +17,7 @@ export const uploadPublicFile = async ( const fileUrl = buildFileUrl(key, "public"); return { - file_type: fileType, + fileType, fileUrl, }; }; @@ -38,7 +38,7 @@ export const uploadPrivateFile = async ( const fileUrl = buildFileUrl(key, "private"); return { - file_type: fileType, + fileType, fileUrl, }; }; diff --git a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.test.tsx b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.test.tsx index 85334f57eb..75ac777f5f 100644 --- a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.test.tsx +++ b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.test.tsx @@ -203,7 +203,7 @@ describe("Modal trigger", () => { ); const mockedPost = mockedAxios.post.mockResolvedValue({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test.jpg", }, }); @@ -236,14 +236,14 @@ describe("Modal trigger", () => { const mockedPost = mockedAxios.post .mockResolvedValueOnce({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test1.jpg", }, }) .mockResolvedValueOnce({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test2.jpg", }, @@ -282,14 +282,14 @@ describe("Modal trigger", () => { mockedAxios.post .mockResolvedValueOnce({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test1.jpg", }, }) .mockResolvedValueOnce({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test2.jpg", }, @@ -343,7 +343,7 @@ describe("Adding tags and syncing state", () => { // Upload one file mockedAxios.post.mockResolvedValueOnce({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test1.jpg", }, }); @@ -406,7 +406,7 @@ describe("Adding tags and syncing state", () => { // Upload one file mockedAxios.post.mockResolvedValueOnce({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test1.jpg", }, }); @@ -472,7 +472,7 @@ describe("Error handling", () => { mockedAxios.post.mockResolvedValueOnce({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test.png", }, }); @@ -524,7 +524,7 @@ describe("Error handling", () => { mockedAxios.post.mockResolvedValue({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test.jpg", }, }); @@ -565,7 +565,7 @@ describe("Error handling", () => { mockedAxios.post.mockResolvedValue({ data: { - file_type: "image/png", + fileType: "image/png", fileUrl: "https://api.editor.planx.dev/file/private/gws7l5d1/test.jpg", }, });