Skip to content

Commit 20da873

Browse files
committedNov 29, 2017
test: no "link" header is sent if there are no pages
1 parent 7f3528a commit 20da873

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed
 

‎test/integration/smoke-test.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,30 @@ describe('constructor', () => {
6464
})
6565
})
6666

67-
it('pagination', () => {
67+
it('pagination', (done) => {
6868
nock('https://smoke-test.com')
6969
.get('/organizations')
70-
.query(true)
70+
.query({page: 2, per_page: 1})
7171
.reply(200, [{}], {
72-
'Link': '<https://api.github.com/organizations?since=3>; rel="next", <https://api.github.com/organizations?since=0>; rel="first", <https://api.github.com/organizations?since=1>; rel="prev"',
72+
'Link': '<https://api.github.com/organizations?page=3>; rel="next", <https://api.github.com/organizations?page=0>; rel="first", <https://api.github.com/organizations?page=1>; rel="prev"',
7373
'X-GitHub-Media-Type': 'github.v3; format=json'
7474
})
7575

7676
.get('/organizations')
77-
.query({since: 0})
77+
.query({page: 0})
7878
.reply(200, [{}])
7979
.get('/organizations')
80-
.query({since: 1})
80+
.query({page: 1})
8181
.reply(200, [{}])
8282
.get('/organizations')
83-
.query({since: 3})
83+
.query({page: 3})
8484
.reply(404, {})
8585

8686
const github = new GitHub({
8787
host: 'smoke-test.com'
8888
})
8989

9090
github.orgs.getAll({
91-
org: 'octokit',
9291
per_page: 1,
9392
page: 2
9493
})
@@ -101,7 +100,18 @@ describe('constructor', () => {
101100

102101
const customHeaders = {foo: 'bar'}
103102
const callback = () => {}
104-
github.getFirstPage(result, callback)
103+
github.getFirstPage(result, (error, result) => {
104+
if (error) {
105+
return done(error)
106+
}
107+
108+
should.not.throw(() => {
109+
github.hasPreviousPage(result)
110+
})
111+
should.not.exist(github.hasPreviousPage(result))
112+
113+
done()
114+
})
105115
github.getPreviousPage(result, customHeaders)
106116
github.getNextPage(result).catch(callback)
107117
github.getLastPage(result, customHeaders, (error) => {
@@ -110,11 +120,6 @@ describe('constructor', () => {
110120

111121
// test error with promise
112122
github.getLastPage(result).catch(callback)
113-
114-
// getNextPage(link, headers, callback)
115-
// getPreviousPage(link, headers, callback)
116-
// getFirstPage(link, headers, callback)
117-
// getLastPage(link, headers, callback)
118123
})
119124
})
120125
})

0 commit comments

Comments
 (0)
Please sign in to comment.