-
-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Issue #764: Add custom year #2107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 8 commits
ecfd948
c0ec7fc
d2c4dfd
4b15721
b74d5be
a8f8bdf
6fa5759
150e13a
15f9303
afb417b
eb445fa
af6553e
de4cefa
d7dd5b5
573af5d
1939ffd
4678af5
5b65614
03366e5
0c3d572
b24733a
4adc788
e729141
7c30597
94d9612
e53a04e
4c3629b
b60aa8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -253,4 +253,74 @@ describe("Test fetchStats", () => { | |||||||||
rank, | ||||||||||
}); | ||||||||||
}); | ||||||||||
|
||||||||||
it("should get present year commits when provide no year", async () => { | ||||||||||
const data2003 = {...data, data: | ||||||||||
{...data.data, user: | ||||||||||
{...data.data.user, contributionsCollection: { | ||||||||||
totalCommitContributions: 2003, | ||||||||||
restrictedContributionsCount: 3, | ||||||||||
}}}} | ||||||||||
mock.onPost("https://api.github.com/graphql").reply((cfg) => { | ||||||||||
if (cfg.data.includes("contributionsCollection(from: 2003-01-01T00:00:00Z)")) | ||||||||||
return [200, data2003]; | ||||||||||
return [200, data]; | ||||||||||
}); | ||||||||||
|
||||||||||
let stats = await fetchStats("anuraghazra", true, false, []); | ||||||||||
const rank = calculateRank({ | ||||||||||
totalCommits: 150, | ||||||||||
totalRepos: 5, | ||||||||||
followers: 100, | ||||||||||
contributions: 61, | ||||||||||
stargazers: 400, | ||||||||||
prs: 300, | ||||||||||
issues: 200, | ||||||||||
}); | ||||||||||
|
||||||||||
expect(stats).toStrictEqual({ | ||||||||||
contributedTo: 61, | ||||||||||
name: "Anurag Hazra", | ||||||||||
totalCommits: 150, | ||||||||||
totalIssues: 200, | ||||||||||
totalPRs: 300, | ||||||||||
totalStars: 400, | ||||||||||
rank, | ||||||||||
}); | ||||||||||
}); | ||||||||||
|
||||||||||
it("should get commits of provided year", async () => { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the other test, which tested whether the current year is returned when no year is supplied. I did this because this is already tested in: github-readme-stats/tests/fetchStats.test.js Line 127 in af6553e
github-readme-stats/tests/fetchStats.test.js Line 216 in af6553e
and github-readme-stats/tests/fetchStats.test.js Line 191 in af6553e
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @anuraghazra, are you okay with this implicit testing, or do you want to have an explicit test like @vzsky did in github-readme-stats/tests/fetchStats.test.js Line 193 in 4b15721
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did that just to be sure that the mocked function works fine. I think deleting that is probably okay since the mocked function was tested and is not likely to get changed. |
||||||||||
const data2003 = {...data, data: | ||||||||||
{...data.data, user: | ||||||||||
{...data.data.user, contributionsCollection: { | ||||||||||
totalCommitContributions: 2003, | ||||||||||
restrictedContributionsCount: 3, | ||||||||||
}}}} | ||||||||||
mock.onPost("https://api.github.com/graphql").reply((cfg) => { | ||||||||||
if (cfg.data.includes(`"starttime":"2003-01-01T00:00:00Z"`)) | ||||||||||
return [200, data2003]; | ||||||||||
return [200, data]; | ||||||||||
}); | ||||||||||
|
||||||||||
let stats = await fetchStats("anuraghazra", true, false, [], 2003); | ||||||||||
const rank = calculateRank({ | ||||||||||
totalCommits: 2006, | ||||||||||
totalRepos: 5, | ||||||||||
followers: 100, | ||||||||||
contributions: 61, | ||||||||||
stargazers: 400, | ||||||||||
prs: 300, | ||||||||||
issues: 200, | ||||||||||
}); | ||||||||||
|
||||||||||
expect(stats).toStrictEqual({ | ||||||||||
contributedTo: 61, | ||||||||||
name: "Anurag Hazra", | ||||||||||
totalCommits: 2006, | ||||||||||
totalIssues: 200, | ||||||||||
totalPRs: 300, | ||||||||||
totalStars: 400, | ||||||||||
rank, | ||||||||||
}); | ||||||||||
}); | ||||||||||
}); |
Uh oh!
There was an error while loading. Please reload this page.