From 9da6a4f0b2714f6dc1dfd9e7357f717ff2f1a4d8 Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Sat, 4 Dec 2021 20:17:55 +0100 Subject: [PATCH] fix: fix stats and language tests (#3) * fix: fix stats and language tests * fix: fixes uncatched merge conflicts * fix: remove hide argument from 'fetchTopLanguages' call This commit removes the `hide` argument from the `fetchTopLanguages` call found in the `top-lang.js` file. This was done since this was leftover from 465faa7. --- api/top-langs.js | 2 -- src/fetchers/stats-fetcher.js | 1 - tests/fetchStats.test.js | 8 ++++---- tests/fetchTopLanguages.test.js | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/api/top-langs.js b/api/top-langs.js index bf8cb7ef59d54..068745d9b1a50 100644 --- a/api/top-langs.js +++ b/api/top-langs.js @@ -47,8 +47,6 @@ module.exports = async (req, res) => { username, parseArray(role), parseArray(exclude_repo), - parseArray(role), - parseArray(hide), ); const cacheSeconds = clampValue( diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js index 674f22ea29bf7..c01db11b5a02f 100644 --- a/src/fetchers/stats-fetcher.js +++ b/src/fetchers/stats-fetcher.js @@ -92,7 +92,6 @@ async function fetchStats( ownerAffiliations, count_private = false, include_all_commits = false, - ownerAffiliations, ) { if (!username) throw Error("Invalid username"); diff --git a/tests/fetchStats.test.js b/tests/fetchStats.test.js index f732182f8fe5a..f6a332eab5591 100644 --- a/tests/fetchStats.test.js +++ b/tests/fetchStats.test.js @@ -52,7 +52,7 @@ describe("Test fetchStats", () => { it("should fetch correct stats", async () => { mock.onPost("https://api.github.com/graphql").reply(200, data); - let stats = await fetchStats("anuraghazra"); + let stats = await fetchStats("anuraghazra", []); const rank = calculateRank({ totalCommits: 100, totalRepos: 5, @@ -77,7 +77,7 @@ describe("Test fetchStats", () => { it("should throw error", async () => { mock.onPost("https://api.github.com/graphql").reply(200, error); - await expect(fetchStats("anuraghazra")).rejects.toThrow( + await expect(fetchStats("anuraghazra", [])).rejects.toThrow( "Could not resolve to a User with the login of 'noname'.", ); }); @@ -85,7 +85,7 @@ describe("Test fetchStats", () => { it("should fetch and add private contributions", async () => { mock.onPost("https://api.github.com/graphql").reply(200, data); - let stats = await fetchStats("anuraghazra", true); + let stats = await fetchStats("anuraghazra", [], true); const rank = calculateRank({ totalCommits: 150, totalRepos: 5, @@ -113,7 +113,7 @@ describe("Test fetchStats", () => { .onGet("https://api.github.com/search/commits?q=author:anuraghazra") .reply(200, { total_count: 1000 }); - let stats = await fetchStats("anuraghazra", true, true); + let stats = await fetchStats("anuraghazra", [], true, true); const rank = calculateRank({ totalCommits: 1050, totalRepos: 5, diff --git a/tests/fetchTopLanguages.test.js b/tests/fetchTopLanguages.test.js index f9aaa024390e5..2df977f1a9c90 100644 --- a/tests/fetchTopLanguages.test.js +++ b/tests/fetchTopLanguages.test.js @@ -59,7 +59,7 @@ describe("FetchTopLanguages", () => { it("should fetch correct language data", async () => { mock.onPost("https://api.github.com/graphql").reply(200, data_langs); - let repo = await fetchTopLanguages("anuraghazra"); + let repo = await fetchTopLanguages("anuraghazra", []); expect(repo).toStrictEqual({ HTML: { color: "#0f0", @@ -77,7 +77,7 @@ describe("FetchTopLanguages", () => { it("should throw error", async () => { mock.onPost("https://api.github.com/graphql").reply(200, error); - await expect(fetchTopLanguages("anuraghazra")).rejects.toThrow( + await expect(fetchTopLanguages("anuraghazra", [])).rejects.toThrow( "Could not resolve to a User with the login of 'noname'.", ); });