refactor(stats card fetcher): improve could not fetch total commits error message (#3255)

This commit is contained in:
Alexandr Garbuzov authored and GitHub committed 2023-09-21 20:30:24 +02:00
1 parent 12f84f89c8
commit 65c3300189
2 files changed
+22 -1

No files matched your search

+18
View File
@@ -304,4 +304,22 @@ describe("Test /api/", () => {
renderError("Something went wrong", "Language not found"),
);
});
it("should render error card when include_all_commits true and upstream API fails", async () => {
mock
.onGet("https://api.github.com/search/commits?q=author:anuraghazra")
.reply(200, { error: "Some test error message" });
const { req, res } = faker(
{ username: "anuraghazra", include_all_commits: true },
data_stats,
);
await api(req, res);
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(
renderError("Could not fetch total commits.", "Please try again later"),
);
});
});