tests: Add Wakatime fetcher error response test to increase coverage (#3112)

This commit is contained in:
Alexandr Garbuzov 2023-08-21 10:09:18 +03:00 committed by GitHub
parent 4e69e3a358
commit 272c712a36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,13 +205,21 @@ describe("Wakatime fetcher", () => {
`);
});
it("should throw error", async () => {
it("should throw error if username param missing", async () => {
mock.onGet(/\/https:\/\/wakatime\.com\/api/).reply(404, wakaTimeData);
await expect(fetchWakatimeStats("noone")).rejects.toThrow(
'Missing params "username" make sure you pass the parameters in URL',
);
});
it("should throw error if username is not found", async () => {
mock.onGet(/\/https:\/\/wakatime\.com\/api/).reply(404, wakaTimeData);
await expect(fetchWakatimeStats({ username: "noone" })).rejects.toThrow(
"Could not resolve to a User with the login of 'noone'",
);
});
});
export { wakaTimeData };