mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-05-17 14:59:23 +00:00
test: fix mistaken pageInfo.endCursor keys (#2657)
The previous mock logic was too simplistic and has been fixed in the commit. If the mock logic had been properly implemented, then the mistaken pageInfo.endCursor keys should have made the test case "should fetch two pages of stars if 'FETCH_MULTI_PAGE_STARS' env variable is set to `true`" stuck.
This commit is contained in:
+1
-1
@@ -43,7 +43,7 @@ const data_stats = {
|
||||
nodes: [{ stargazers: { totalCount: 100 } }],
|
||||
pageInfo: {
|
||||
hasNextPage: false,
|
||||
cursor: "cursor",
|
||||
endCursor: "cursor",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -27,7 +27,7 @@ const data_stats = {
|
||||
],
|
||||
pageInfo: {
|
||||
hasNextPage: true,
|
||||
cursor: "cursor",
|
||||
endCursor: "cursor",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -44,7 +44,7 @@ const data_repo = {
|
||||
],
|
||||
pageInfo: {
|
||||
hasNextPage: false,
|
||||
cursor: "cursor",
|
||||
endCursor: "cursor",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -64,7 +64,7 @@ const data_repo_zero_stars = {
|
||||
],
|
||||
pageInfo: {
|
||||
hasNextPage: true,
|
||||
cursor: "cursor",
|
||||
endCursor: "cursor",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -86,11 +86,12 @@ const mock = new MockAdapter(axios);
|
||||
|
||||
beforeEach(() => {
|
||||
process.env.FETCH_MULTI_PAGE_STARS = "false"; // Set to `false` to fetch only one page of stars.
|
||||
mock
|
||||
.onPost("https://api.github.com/graphql")
|
||||
.replyOnce(200, data_stats)
|
||||
.onPost("https://api.github.com/graphql")
|
||||
.replyOnce(200, data_repo);
|
||||
mock.onPost("https://api.github.com/graphql").reply((cfg) => {
|
||||
return [
|
||||
200,
|
||||
cfg.data.includes("contributionsCollection") ? data_stats : data_repo,
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user