Skip to content

Commit 51e9108

Browse files
committed
chore: update test file
1 parent 67c473a commit 51e9108

File tree

1 file changed

+1
-59
lines changed

1 file changed

+1
-59
lines changed

tests/renderStatsCard.test.ts

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe("Test GitHub Readme Profile API", () => {
5454
json: jest.fn(),
5555
send: jest.fn(),
5656
setHeader: jest.fn(),
57-
status: jest.fn().mockReturnThis(),
57+
status: jest.fn(),
5858
};
5959

6060
jest.clearAllMocks();
@@ -73,17 +73,6 @@ describe("Test GitHub Readme Profile API", () => {
7373
expect(mockResponse.setHeader).toHaveBeenCalledWith("Cache-Control", "s-maxage=7200, stale-while-revalidate");
7474
});
7575

76-
it("should return an error response when GitHub API fails", async () => {
77-
mockRequest.query.username = "FajarKim";
78-
mockRequest.query.format = "json";
79-
(getData as jest.Mock).mockRejectedValueOnce(new Error("GitHub API error"));
80-
81-
await readmeStats(mockRequest, mockResponse);
82-
83-
expect(mockResponse.status).toHaveBeenCalledWith(500);
84-
expect(mockResponse.send).toHaveBeenCalledWith("Error fetching data from GitHub API");
85-
});
86-
8776
it("should handle request and generate SVG response", async () => {
8877
mockRequest.query.username = "FajarKim";
8978
mockRequest.query.format = "svg";
@@ -165,53 +154,6 @@ describe("Test GitHub Readme Profile API", () => {
165154
expect(mockResponse.json).not.toHaveBeenCalled();
166155
});
167156

168-
it("should validate User data conforms to interface", async () => {
169-
mockRequest.query.username = "FajarKim";
170-
(getData as jest.Mock).mockResolvedValueOnce(exampleUserData);
171-
172-
await readmeStats(mockRequest, mockResponse);
173-
174-
const userData = mockResponse.json.mock.calls[0][0];
175-
expect(userData).toHaveProperty("name");
176-
expect(userData).toHaveProperty("login");
177-
expect(userData).toHaveProperty("avatarUrl");
178-
expect(userData.repositories.totalCount).toBeGreaterThanOrEqual(0);
179-
});
180-
181-
it("should handle user with zero contributions", async () => {
182-
const zeroContributionsData = {
183-
...exampleUserData,
184-
totalCommitContributions: 0,
185-
restrictedContributionsCount: 0,
186-
totalPullRequestReviewContributions: 0,
187-
};
188-
189-
(getData as jest.Mock).mockResolvedValueOnce(zeroContributionsData);
190-
191-
mockRequest.query.username = "FajarKim";
192-
193-
await readmeStats(mockRequest, mockResponse);
194-
195-
expect(mockResponse.json).toHaveBeenCalledWith(zeroContributionsData);
196-
});
197-
198-
it("should handle very large contribution data without errors", async () => {
199-
const highContributionsData = {
200-
...exampleUserData,
201-
totalCommitContributions: 100000,
202-
restrictedContributionsCount: 50000,
203-
totalPullRequestReviewContributions: 30000,
204-
};
205-
206-
(getData as jest.Mock).mockResolvedValueOnce(highContributionsData);
207-
208-
mockRequest.query.username = "FajarKim";
209-
210-
await readmeStats(mockRequest, mockResponse);
211-
212-
expect(mockResponse.json).toHaveBeenCalledWith(highContributionsData);
213-
});
214-
215157
it("should correctly fetch user join date and total commits since joining", async () => {
216158
mockRequest.query.username = "FajarKim";
217159
(getData as jest.Mock).mockResolvedValueOnce(exampleUserData);

0 commit comments

Comments
 (0)