Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/services/common-api.postNoBody.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ describe("commonApiPostWithoutBodyAndResponse", () => {
});
await expect(
commonApiPostWithoutBodyAndResponse({ endpoint: "e" })
).rejects.toThrow("err");
).rejects.toBe("err");
});
});
4 changes: 2 additions & 2 deletions __tests__/services/common-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("commonApiFetch", () => {
json: async () => ({ error: "err" }),
});

await expect(commonApiFetch({ endpoint: "bad" })).rejects.toThrow("err");
await expect(commonApiFetch({ endpoint: "bad" })).rejects.toBe("err");
expect(fetchMock).toHaveBeenCalledWith(
"https://api.test.6529.io/api/bad",
expect.objectContaining({
Expand Down Expand Up @@ -103,7 +103,7 @@ describe("commonApiPost", () => {
json: async () => ({ error: "err" }),
});

await expect(commonApiPost({ endpoint: "e", body: {} })).rejects.toThrow(
await expect(commonApiPost({ endpoint: "e", body: {} })).rejects.toBe(
"err"
);
expect(fetchMock).toHaveBeenCalledWith(
Expand Down
2 changes: 1 addition & 1 deletion services/api/common-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}
}

throw new Error(errorMessage);
return Promise.reject(errorMessage);

Check failure on line 55 in services/api/common-api.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `throw error` over `return Promise.reject(error)`.

See more on https://sonarcloud.io/project/issues?id=6529-Collections_6529seize-frontend&issues=AZqlvItZ9MqIcEQ4SFAX&open=AZqlvItZ9MqIcEQ4SFAX&pullRequest=1614

Check warning on line 55 in services/api/common-api.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Expected the Promise rejection reason to be an Error.

See more on https://sonarcloud.io/project/issues?id=6529-Collections_6529seize-frontend&issues=AZqlvItZ9MqIcEQ4SFAW&open=AZqlvItZ9MqIcEQ4SFAW&pullRequest=1614
};

const executeApiRequest = async <T>(
Expand Down