Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit65c3300

Browse files
authored
refactor(stats card fetcher): improve could not fetch total commits error message (anuraghazra#3255)
1 parent12f84f8 commit65c3300

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎src/fetchers/stats-fetcher.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ const totalCommitsFetcher = async (username) => {
180180

181181
consttotalCount=res.data.total_count;
182182
if(!totalCount||isNaN(totalCount)){
183-
thrownewError("Could not fetch total commits.");
183+
thrownewCustomError(
184+
"Could not fetch total commits.",
185+
CustomError.GRAPHQL_ERROR,
186+
);
184187
}
185188
returntotalCount;
186189
};

‎tests/api.test.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,22 @@ describe("Test /api/", () => {
304304
renderError("Something went wrong","Language not found"),
305305
);
306306
});
307+
308+
it("should render error card when include_all_commits true and upstream API fails",async()=>{
309+
mock
310+
.onGet("https://api.github.com/search/commits?q=author:anuraghazra")
311+
.reply(200,{error:"Some test error message"});
312+
313+
const{ req, res}=faker(
314+
{username:"anuraghazra",include_all_commits:true},
315+
data_stats,
316+
);
317+
318+
awaitapi(req,res);
319+
320+
expect(res.setHeader).toBeCalledWith("Content-Type","image/svg+xml");
321+
expect(res.send).toBeCalledWith(
322+
renderError("Could not fetch total commits.","Please try again later"),
323+
);
324+
});
307325
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp