Repository: anuraghazra/github-readme-stats
File: tests/fetchStats.test.js (JavaScript)

Code before:

    let stats = await fetchStats("anuraghazra", true, true, ["test-repo-1"]);
    const rank = calculateRank({
      totalCommits: 1050,
      totalRepos: 5,
      followers: 100,
      contributions: 61,
      // stargazers: 300, // NOTE: Temporarily disable fetching of multiple pages. Done because of #2130.
      stargazers: 200, // NOTE: Temporarily disable fetching of multiple pages. Done because of #2130.
      prs: 300,
      issues: 200,
    });

    expect(stats).toStrictEqual({
      contributedTo: 61,
      name: "Anurag Hazra",
      totalCommits: 1050,
      totalIssues: 200,
      totalPRs: 300,
      // totalStars: 300, // NOTE: Temporarily disable fetching of multiple pages. Done because of #2130.
      totalStars: 200, // NOTE: Temporarily disable fetching of multiple pages. Done because of #2130.
      rank,
    });
  });

  it("should get commits of provided year", async () => {
    let stats = await fetchStats("anuraghazra", true, false, [], 2003);
    const rank = calculateRank({
      totalCommits: 2006,
      totalRepos: 5,
      followers: 100,
      contributions: 61,
      // stargazers: 400, // NOTE: Temporarily disable fetching of multiple pages. Done because of #2130.
      stargazers: 300, // NOTE: Temporarily disable fetching of multiple pages. Done because of #2130.
      prs: 300,
      issues: 200,
    });

    expect(stats).toStrictEqual({
      contributedTo: 61,
      name: "Anurag Hazra",
      totalCommits: 2006,
      totalIssues: 200,
      totalPRs: 300,
      // totalStars: 400, // NOTE: Temporarily disable fetching of multiple pages. Done because of #2130.
      totalStars: 300, // NOTE: Temporarily disable fetching of multiple pages. Done because of #2130.
      rank,
    });
  });
});


Review comment (suggestion):
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:

https://github.com/anuraghazra/github-readme-stats/blob/af6553ecf550fcbd6259b05294381f6cf2e126a2/tests/fetchStats.test.js#L127

https://github.com/anuraghazra/github-readme-stats/blob/af6553ecf550fcbd6259b05294381f6cf2e126a2/tests/fetchStats.test.js#L216

and

https://github.com/anuraghazra/github-readme-stats/blob/af6553ecf550fcbd6259b05294381f6cf2e126a2/tests/fetchStats.test.js#L191


Code after:
    const rank = calculateRank({
      all_commits: true,
      commits: 1000,
      prs: 300,
      reviews: 50,
      issues: 200,
      repos: 5,
      stars: 200,
      followers: 100,
    });

    expect(stats).toStrictEqual({
      contributedTo: 61,
      name: "Anurag Hazra",
      totalCommits: 1000,
      totalIssues: 200,
      totalPRs: 300,
      totalPRsMerged: 0,
      mergedPRsPercentage: 0,
      totalReviews: 50,
      totalStars: 200,
      totalDiscussionsStarted: 0,
      totalDiscussionsAnswered: 0,
      rank,
    });
  });

  it("should fetch two pages of stars if 'FETCH_MULTI_PAGE_STARS' env variable is set to `true`", async () => {
    process.env.FETCH_MULTI_PAGE_STARS = true;

    let stats = await fetchStats("anuraghazra");
    const rank = calculateRank({
      all_commits: false,
      commits: 100,
      prs: 300,
      reviews: 50,
      issues: 200,
      repos: 5,
      stars: 400,
      followers: 100,
    });

    expect(stats).toStrictEqual({
      contributedTo: 61,
      name: "Anurag Hazra",
      totalCommits: 100,
      totalIssues: 200,
      totalPRs: 300,
      totalPRsMerged: 0,
      mergedPRsPercentage: 0,
      totalReviews: 50,