From cad3f65c7270beba6992b373ad9b4bf26f399614 Mon Sep 17 00:00:00 2001 From: tejaskh3 Date: Sun, 5 May 2024 12:18:06 +0530 Subject: [PATCH] refactor: add message in constant responses --- src/constants/responses.ts | 2 ++ src/controllers/taskUpdatesHandler.ts | 4 +--- tests/unit/handlers/taskUpdateHandler.test.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/constants/responses.ts b/src/constants/responses.ts index 44007852..bff6a2c0 100644 --- a/src/constants/responses.ts +++ b/src/constants/responses.ts @@ -77,3 +77,5 @@ export const INVALID_TOKEN_FORMAT = "Invalid Authentication header format. Expected 'Bearer '"; export const AUTHENTICATION_ERROR = "Invalid Authentication token"; +export const TASK_UPDATE_SENT_MESSAGE = + "Task update sent on Discord's tracking-updates channel."; diff --git a/src/controllers/taskUpdatesHandler.ts b/src/controllers/taskUpdatesHandler.ts index 8656ec74..a509d80a 100644 --- a/src/controllers/taskUpdatesHandler.ts +++ b/src/controllers/taskUpdatesHandler.ts @@ -25,9 +25,7 @@ export const sendTaskUpdatesHandler = async (request: IRequest, env: env) => { taskTitle, env ); - return new JSONResponse( - "Task update sent on Discord's tracking-updates channel." - ); + return new JSONResponse(response.TASK_UPDATE_SENT_MESSAGE); } catch (error: any) { return new JSONResponse({ res: response.INTERNAL_SERVER_ERROR, diff --git a/tests/unit/handlers/taskUpdateHandler.test.ts b/tests/unit/handlers/taskUpdateHandler.test.ts index cd8e0d4a..f6cff2de 100644 --- a/tests/unit/handlers/taskUpdateHandler.test.ts +++ b/tests/unit/handlers/taskUpdateHandler.test.ts @@ -67,6 +67,6 @@ describe("sendTaskUpdatesHandler", () => { ); expect(result.status).toBe(200); const res: JSONResponse = await result.json(); - expect(res).toBe("Task update sent on Discord's tracking-updates channel."); + expect(res).toBe(response.TASK_UPDATE_SENT_MESSAGE); }); });