fix: total commit counts (#211)

* fix: wip fix total commit counts

* tests: added tests

* chore: remove console logs

* docs: added docs for include_all_commits

* chore: increased value offset x

* chore: added reference/links comments

* docs: updated docs
This commit is contained in:
Anurag Hazra
2020-07-31 13:37:39 +05:30
committed by GitHub
parent a4486d0327
commit 416f027fae
6 changed files with 117 additions and 11 deletions

View File

@ -9,7 +9,10 @@ const data = {
user: {
name: "Anurag Hazra",
repositoriesContributedTo: { totalCount: 61 },
contributionsCollection: { totalCommitContributions: 100, restrictedContributionsCount: 50 },
contributionsCollection: {
totalCommitContributions: 100,
restrictedContributionsCount: 50,
},
pullRequests: { totalCount: 300 },
issues: { totalCount: 200 },
followers: { totalCount: 100 },
@ -102,4 +105,32 @@ describe("Test fetchStats", () => {
rank,
});
});
});
it("should fetch total commits", async () => {
mock.onPost("https://api.github.com/graphql").reply(200, data);
mock
.onGet("https://api.github.com/search/commits?q=author:anuraghazra")
.reply(200, { total_count: 1000 });
let stats = await fetchStats("anuraghazra", true, true);
const rank = calculateRank({
totalCommits: 1000 + 150,
totalRepos: 5,
followers: 100,
contributions: 61,
stargazers: 400,
prs: 300,
issues: 200,
});
expect(stats).toStrictEqual({
contributedTo: 61,
name: "Anurag Hazra",
totalCommits: 1000 + 150,
totalIssues: 200,
totalPRs: 300,
totalStars: 400,
rank,
});
});
});