Skip to content

Commit

Permalink
refactor: change variable name for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajjs committed Nov 10, 2024
1 parent f2cabae commit df52b33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions tests/unit/handlers/deleteGuildRoleHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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",
Expand All @@ -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({
Expand All @@ -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);
});
});
8 changes: 4 additions & 4 deletions tests/unit/utils/deleteGuildRole.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit df52b33

Please sign in to comment.