github-profile-trophy-reiyu.../src/__tests__/user_info.test.ts
luo jiyin 0dbd570fb3
fix: handle GitHub GraphQL star failures (#454)
* fix(request): fail on GraphQL errors instead of returning partial data

* fix(user-info,schemas): use stargazerCount instead of stargazers connection

* test(request): reject partial GraphQL responses

* fix(config): use PAT names for GitHub tokens

* fix: validate star counts and GraphQL failures

* revert: preserve GitHub token environment names
2026-07-25 08:59:47 +09:00

41 lines
1 KiB
TypeScript

import { assertEquals } from "../../deps.ts";
import { UserInfo } from "../user_info.ts";
Deno.test("UserInfo calculates total stargazers", () => {
const userInfo = new UserInfo(
{
createdAt: "2025-01-01T00:00:00Z",
contributionsCollection: {
restrictedContributionsCount: 0,
totalCommitContributions: 0,
totalPullRequestReviewContributions: 0,
},
organizations: { totalCount: 0 },
followers: { totalCount: 0 },
},
{
openIssues: { totalCount: 0 },
closedIssues: { totalCount: 0 },
},
{ pullRequests: { totalCount: 0 } },
{
repositories: {
totalCount: 2,
nodes: [
{
languages: { nodes: [] },
stargazerCount: 3,
createdAt: "2025-01-01T00:00:00Z",
},
{
languages: { nodes: [] },
stargazerCount: 5,
createdAt: "2025-01-02T00:00:00Z",
},
],
},
},
);
assertEquals(userInfo.totalStargazers, 8);
});