From 6ccad3f94b39dd2f4cdcc438ab0686b9897c6522 Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov Date: Mon, 21 Aug 2023 10:09:18 +0300 Subject: [PATCH] tests: Add Wakatime fetcher error response test to increase coverage (#3112) --- tests/fetchWakatime.test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/fetchWakatime.test.js b/tests/fetchWakatime.test.js index 6735a05a47bea..fb337345bef0b 100644 --- a/tests/fetchWakatime.test.js +++ b/tests/fetchWakatime.test.js @@ -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 };