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 setdebarr committed Jan 12, 2024
1 parent 90434ab commit 6ccad3f
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 6ccad3f

Please sign in to comment.