From df52b33ec014478e2de8f8b71289a890acc99173 Mon Sep 17 00:00:00 2001 From: Pankaj Sha Date: Sun, 10 Nov 2024 20:13:01 +0530 Subject: [PATCH] refactor: change variable name for better readability --- .../handlers/deleteGuildRoleHandler.test.ts | 18 +++++++++--------- tests/unit/utils/deleteGuildRole.test.ts | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/unit/handlers/deleteGuildRoleHandler.test.ts b/tests/unit/handlers/deleteGuildRoleHandler.test.ts index 4fa30964..56b7b759 100644 --- a/tests/unit/handlers/deleteGuildRoleHandler.test.ts +++ b/tests/unit/handlers/deleteGuildRoleHandler.test.ts @@ -59,7 +59,7 @@ describe("deleteGuildRoleHandler", () => { expect(jsonResponse).toEqual(responseConstants.BAD_SIGNATURE); }); it("should return INTERNAL_SERVER_ERROR when response is not ok", async () => { - const mockResponse = responseConstants.INTERNAL_SERVER_ERROR; + const expectedResponse = responseConstants.INTERNAL_SERVER_ERROR; const mockRequest = generateDummyRequestObject({ url: "/roles", params: { @@ -73,13 +73,13 @@ describe("deleteGuildRoleHandler", () => { }); jest .spyOn(deleteGuildRoleUtils, "deleteGuildRole") - .mockResolvedValue(mockResponse); + .mockResolvedValue(expectedResponse); const response = await deleteGuildRoleHandler(mockRequest, guildEnv); const jsonResponse = await response.json(); - expect(jsonResponse).toEqual(mockResponse); + expect(jsonResponse).toEqual(expectedResponse); }); it("should return INTERNAL_SERVER_ERROR when token is not verified", async () => { - const mockResponse = responseConstants.INTERNAL_SERVER_ERROR; + const expectedResponse = responseConstants.INTERNAL_SERVER_ERROR; const mockRequest = generateDummyRequestObject({ url: "/roles", method: "DELETE", @@ -93,13 +93,13 @@ describe("deleteGuildRoleHandler", () => { }); jest .spyOn(verifyTokenUtils, "verifyNodejsBackendAuthToken") - .mockRejectedValue(mockResponse); + .mockRejectedValue(expectedResponse); const response = await deleteGuildRoleHandler(mockRequest, guildEnv); const jsonResponse = await response.json(); - expect(jsonResponse).toEqual(mockResponse); + expect(jsonResponse).toEqual(expectedResponse); }); it("should return ok response", async () => { - const mockResponse = new Response(null, { + const expectedResponse = new Response(null, { status: 204, }); const mockRequest = generateDummyRequestObject({ @@ -122,7 +122,7 @@ describe("deleteGuildRoleHandler", () => { const response = await deleteGuildRoleHandler(mockRequest, guildEnv); expect(verifyTokenSpy).toHaveBeenCalledTimes(1); expect(deleteGuildRoleSpy).toHaveBeenCalledTimes(1); - expect(response).toEqual(mockResponse); - expect(response.status).toEqual(mockResponse.status); + expect(response).toEqual(expectedResponse); + expect(response.status).toEqual(expectedResponse.status); }); }); diff --git a/tests/unit/utils/deleteGuildRole.test.ts b/tests/unit/utils/deleteGuildRole.test.ts index 7808db8e..98c77864 100644 --- a/tests/unit/utils/deleteGuildRole.test.ts +++ b/tests/unit/utils/deleteGuildRole.test.ts @@ -37,18 +37,18 @@ describe("deleteGuildRole", () => { }); it("should return ROLE_REMOVED when response is ok", async () => { - const mockResponse = new Response(null, { + const expectedResponse = new Response(null, { status: 204, }); - jest.spyOn(global, "fetch").mockResolvedValue(mockResponse); + jest.spyOn(global, "fetch").mockResolvedValue(expectedResponse); const result = await deleteGuildRole(guildEnv, roleId); expect(result).toEqual(response.ROLE_REMOVED); expect(global.fetch).toHaveBeenCalledTimes(1); }); it("should return INTERNAL_SERVER_ERROR when response is not ok", async () => { - const mockErrorResponse = new Response(response.INTERNAL_SERVER_ERROR); - jest.spyOn(global, "fetch").mockRejectedValue(mockErrorResponse); + const expectedErrorResponse = new Response(response.INTERNAL_SERVER_ERROR); + jest.spyOn(global, "fetch").mockRejectedValue(expectedErrorResponse); const result = await deleteGuildRole(guildEnv, roleId); expect(result).toEqual(response.INTERNAL_SERVER_ERROR); expect(global.fetch).toHaveBeenCalledTimes(1);