@@ -64,31 +64,30 @@ describe('constructor', () => {
64
64
} )
65
65
} )
66
66
67
- it ( 'pagination' , ( ) => {
67
+ it ( 'pagination' , ( done ) => {
68
68
nock ( 'https://smoke-test.com' )
69
69
. get ( '/organizations' )
70
- . query ( true )
70
+ . query ( { page : 2 , per_page : 1 } )
71
71
. 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"' ,
73
73
'X-GitHub-Media-Type' : 'github.v3; format=json'
74
74
} )
75
75
76
76
. get ( '/organizations' )
77
- . query ( { since : 0 } )
77
+ . query ( { page : 0 } )
78
78
. reply ( 200 , [ { } ] )
79
79
. get ( '/organizations' )
80
- . query ( { since : 1 } )
80
+ . query ( { page : 1 } )
81
81
. reply ( 200 , [ { } ] )
82
82
. get ( '/organizations' )
83
- . query ( { since : 3 } )
83
+ . query ( { page : 3 } )
84
84
. reply ( 404 , { } )
85
85
86
86
const github = new GitHub ( {
87
87
host : 'smoke-test.com'
88
88
} )
89
89
90
90
github . orgs . getAll ( {
91
- org : 'octokit' ,
92
91
per_page : 1 ,
93
92
page : 2
94
93
} )
@@ -101,7 +100,18 @@ describe('constructor', () => {
101
100
102
101
const customHeaders = { foo : 'bar' }
103
102
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
+ } )
105
115
github . getPreviousPage ( result , customHeaders )
106
116
github . getNextPage ( result ) . catch ( callback )
107
117
github . getLastPage ( result , customHeaders , ( error ) => {
@@ -110,11 +120,6 @@ describe('constructor', () => {
110
120
111
121
// test error with promise
112
122
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)
118
123
} )
119
124
} )
120
125
} )
0 commit comments