Skip to content

Commit

Permalink
fix: fix stats and language tests (#3)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
rickstaa authored Dec 4, 2021
1 parent 4a4cec6 commit 9da6a4f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 0 additions & 2 deletions api/top-langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ module.exports = async (req, res) => {
username,
parseArray(role),
parseArray(exclude_repo),
parseArray(role),
parseArray(hide),
);

const cacheSeconds = clampValue(
Expand Down
1 change: 0 additions & 1 deletion src/fetchers/stats-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ async function fetchStats(
ownerAffiliations,
count_private = false,
include_all_commits = false,
ownerAffiliations,
) {
if (!username) throw Error("Invalid username");

Expand Down
8 changes: 4 additions & 4 deletions tests/fetchStats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -77,15 +77,15 @@ 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'.",
);
});

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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/fetchTopLanguages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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'.",
);
});
Expand Down

0 comments on commit 9da6a4f

Please sign in to comment.