@@ -54,7 +54,7 @@ describe("Test GitHub Readme Profile API", () => {
54
54
json : jest . fn ( ) ,
55
55
send : jest . fn ( ) ,
56
56
setHeader : jest . fn ( ) ,
57
- status : jest . fn ( ) . mockReturnThis ( ) ,
57
+ status : jest . fn ( ) ,
58
58
} ;
59
59
60
60
jest . clearAllMocks ( ) ;
@@ -73,17 +73,6 @@ describe("Test GitHub Readme Profile API", () => {
73
73
expect ( mockResponse . setHeader ) . toHaveBeenCalledWith ( "Cache-Control" , "s-maxage=7200, stale-while-revalidate" ) ;
74
74
} ) ;
75
75
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
-
87
76
it ( "should handle request and generate SVG response" , async ( ) => {
88
77
mockRequest . query . username = "FajarKim" ;
89
78
mockRequest . query . format = "svg" ;
@@ -165,53 +154,6 @@ describe("Test GitHub Readme Profile API", () => {
165
154
expect ( mockResponse . json ) . not . toHaveBeenCalled ( ) ;
166
155
} ) ;
167
156
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
-
215
157
it ( "should correctly fetch user join date and total commits since joining" , async ( ) => {
216
158
mockRequest . query . username = "FajarKim" ;
217
159
( getData as jest . Mock ) . mockResolvedValueOnce ( exampleUserData ) ;
0 commit comments