Skip to content

Commit

Permalink
tests: Add Wakatime fetcher error response test to increase coverage (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 authored and devantler committed Sep 24, 2023
1 parent b2a60c7 commit 724f0cf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/fetchWakatime.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

0 comments on commit 724f0cf

Please sign in to comment.