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

Commit0caa4c5

Browse files
authored
test: fix mistaken pageInfo.endCursor keys (anuraghazra#2657)
The previous mock logic was too simplistic and has been fixed in thecommit. If the mock logic had been properly implemented, then themistaken pageInfo.endCursor keys should have made the test case "shouldfetch two pages of stars if 'FETCH_MULTI_PAGE_STARS' env variable is setto `true`" stuck.
1 parent0c2fe4e commit0caa4c5

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

‎tests/api.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const data_stats = {
4343
nodes:[{stargazers:{totalCount:100}}],
4444
pageInfo:{
4545
hasNextPage:false,
46-
cursor:"cursor",
46+
endCursor:"cursor",
4747
},
4848
},
4949
},

‎tests/fetchStats.test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const data_stats = {
2727
],
2828
pageInfo:{
2929
hasNextPage:true,
30-
cursor:"cursor",
30+
endCursor:"cursor",
3131
},
3232
},
3333
},
@@ -44,7 +44,7 @@ const data_repo = {
4444
],
4545
pageInfo:{
4646
hasNextPage:false,
47-
cursor:"cursor",
47+
endCursor:"cursor",
4848
},
4949
},
5050
},
@@ -64,7 +64,7 @@ const data_repo_zero_stars = {
6464
],
6565
pageInfo:{
6666
hasNextPage:true,
67-
cursor:"cursor",
67+
endCursor:"cursor",
6868
},
6969
},
7070
},
@@ -86,11 +86,12 @@ const mock = new MockAdapter(axios);
8686

8787
beforeEach(()=>{
8888
process.env.FETCH_MULTI_PAGE_STARS="false";// Set to `false` to fetch only one page of stars.
89-
mock
90-
.onPost("https://api.github.com/graphql")
91-
.replyOnce(200,data_stats)
92-
.onPost("https://api.github.com/graphql")
93-
.replyOnce(200,data_repo);
89+
mock.onPost("https://api.github.com/graphql").reply((cfg)=>{
90+
return[
91+
200,
92+
cfg.data.includes("contributionsCollection") ?data_stats :data_repo,
93+
];
94+
});
9495
});
9596

9697
afterEach(()=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp