@@ -62,14 +62,14 @@ describe('Test paginate function', () => {
6262 route : 'http://example.com/something' ,
6363 } ) ;
6464
65- expect ( results . links . first ) . toBe ( 'http://example.com/something?limit=4' ) ;
66- expect ( results . links . previous ) . toBe (
65+ expect ( results . links ? .first ) . toBe ( 'http://example.com/something?limit=4' ) ;
66+ expect ( results . links ? .previous ) . toBe (
6767 'http://example.com/something?page=1&limit=4' ,
6868 ) ;
69- expect ( results . links . next ) . toBe (
69+ expect ( results . links ? .next ) . toBe (
7070 'http://example.com/something?page=3&limit=4' ,
7171 ) ;
72- expect ( results . links . last ) . toBe (
72+ expect ( results . links ? .last ) . toBe (
7373 'http://example.com/something?page=3&limit=4' ,
7474 ) ;
7575 } ) ;
@@ -87,16 +87,16 @@ describe('Test paginate function', () => {
8787 } ,
8888 } ) ;
8989
90- expect ( results . links . first ) . toBe (
90+ expect ( results . links ? .first ) . toBe (
9191 'http://example.com/something?page-size=4' ,
9292 ) ;
93- expect ( results . links . previous ) . toBe (
93+ expect ( results . links ? .previous ) . toBe (
9494 'http://example.com/something?current-page=1&page-size=4' ,
9595 ) ;
96- expect ( results . links . next ) . toBe (
96+ expect ( results . links ? .next ) . toBe (
9797 'http://example.com/something?current-page=3&page-size=4' ,
9898 ) ;
99- expect ( results . links . last ) . toBe (
99+ expect ( results . links ? .last ) . toBe (
100100 'http://example.com/something?current-page=3&page-size=4' ,
101101 ) ;
102102 } ) ;
@@ -113,14 +113,14 @@ describe('Test paginate function', () => {
113113 } ,
114114 } ) ;
115115
116- expect ( results . links . first ) . toBe ( 'http://example.com/something?limit=4' ) ;
117- expect ( results . links . previous ) . toBe (
116+ expect ( results . links ? .first ) . toBe ( 'http://example.com/something?limit=4' ) ;
117+ expect ( results . links ? .previous ) . toBe (
118118 'http://example.com/something?current-page=1&limit=4' ,
119119 ) ;
120- expect ( results . links . next ) . toBe (
120+ expect ( results . links ? .next ) . toBe (
121121 'http://example.com/something?current-page=3&limit=4' ,
122122 ) ;
123- expect ( results . links . last ) . toBe (
123+ expect ( results . links ? .last ) . toBe (
124124 'http://example.com/something?current-page=3&limit=4' ,
125125 ) ;
126126 } ) ;
@@ -137,16 +137,16 @@ describe('Test paginate function', () => {
137137 } ,
138138 } ) ;
139139
140- expect ( results . links . first ) . toBe (
140+ expect ( results . links ? .first ) . toBe (
141141 'http://example.com/something?page-size=4' ,
142142 ) ;
143- expect ( results . links . previous ) . toBe (
143+ expect ( results . links ? .previous ) . toBe (
144144 'http://example.com/something?page=1&page-size=4' ,
145145 ) ;
146- expect ( results . links . next ) . toBe (
146+ expect ( results . links ? .next ) . toBe (
147147 'http://example.com/something?page=3&page-size=4' ,
148148 ) ;
149- expect ( results . links . last ) . toBe (
149+ expect ( results . links ? .last ) . toBe (
150150 'http://example.com/something?page=3&page-size=4' ,
151151 ) ;
152152 } ) ;
@@ -160,12 +160,12 @@ describe('Test paginate function', () => {
160160 route : 'http://example.com/something' ,
161161 } ) ;
162162
163- expect ( results . links . first ) . toBe ( 'http://example.com/something?limit=4' ) ;
164- expect ( results . links . previous ) . toBe ( '' ) ;
165- expect ( results . links . next ) . toBe (
163+ expect ( results . links ? .first ) . toBe ( 'http://example.com/something?limit=4' ) ;
164+ expect ( results . links ? .previous ) . toBe ( '' ) ;
165+ expect ( results . links ? .next ) . toBe (
166166 'http://example.com/something?page=2&limit=4' ,
167167 ) ;
168- expect ( results . links . last ) . toBe (
168+ expect ( results . links ? .last ) . toBe (
169169 'http://example.com/something?page=3&limit=4' ,
170170 ) ;
171171 } ) ;
@@ -179,12 +179,12 @@ describe('Test paginate function', () => {
179179 route : 'http://example.com/something' ,
180180 } ) ;
181181
182- expect ( results . links . first ) . toBe ( 'http://example.com/something?limit=4' ) ;
183- expect ( results . links . previous ) . toBe (
182+ expect ( results . links ? .first ) . toBe ( 'http://example.com/something?limit=4' ) ;
183+ expect ( results . links ? .previous ) . toBe (
184184 'http://example.com/something?page=2&limit=4' ,
185185 ) ;
186- expect ( results . links . next ) . toBe ( '' ) ;
187- expect ( results . links . last ) . toBe (
186+ expect ( results . links ? .next ) . toBe ( '' ) ;
187+ expect ( results . links ? .last ) . toBe (
188188 'http://example.com/something?page=3&limit=4' ,
189189 ) ;
190190 } ) ;
@@ -198,12 +198,12 @@ describe('Test paginate function', () => {
198198 route : 'http://example.com/something' ,
199199 } ) ;
200200
201- expect ( results . links . first ) . toBe ( 'http://example.com/something?limit=4' ) ;
202- expect ( results . links . previous ) . toBe ( '' ) ;
203- expect ( results . links . next ) . toBe (
201+ expect ( results . links ? .first ) . toBe ( 'http://example.com/something?limit=4' ) ;
202+ expect ( results . links ? .previous ) . toBe ( '' ) ;
203+ expect ( results . links ? .next ) . toBe (
204204 'http://example.com/something?page=2&limit=4' ,
205205 ) ;
206- expect ( results . links . last ) . toBe (
206+ expect ( results . links ? .last ) . toBe (
207207 'http://example.com/something?page=3&limit=4' ,
208208 ) ;
209209 } ) ;
@@ -222,12 +222,12 @@ describe('Test paginate function', () => {
222222 } ) ;
223223
224224 expect ( results . items . length ) . toBe ( 5 ) ;
225- expect ( results . links . first ) . toBe ( 'http://example.com/something?limit=10' ) ;
226- expect ( results . links . previous ) . toBe (
225+ expect ( results . links ? .first ) . toBe ( 'http://example.com/something?limit=10' ) ;
226+ expect ( results . links ? .previous ) . toBe (
227227 'http://example.com/something?page=1&limit=10' ,
228228 ) ;
229- expect ( results . links . next ) . toBe ( '' ) ;
230- expect ( results . links . last ) . toBe (
229+ expect ( results . links ? .next ) . toBe ( '' ) ;
230+ expect ( results . links ? .last ) . toBe (
231231 'http://example.com/something?page=2&limit=10' ,
232232 ) ;
233233 expect ( consoleMock ) . toHaveBeenCalledWith (
@@ -249,12 +249,12 @@ describe('Test paginate function', () => {
249249 } ) ;
250250
251251 expect ( results . items . length ) . toBe ( 4 ) ;
252- expect ( results . links . first ) . toBe ( 'http://example.com/something?limit=4' ) ;
253- expect ( results . links . previous ) . toBe ( '' ) ;
254- expect ( results . links . next ) . toBe (
252+ expect ( results . links ? .first ) . toBe ( 'http://example.com/something?limit=4' ) ;
253+ expect ( results . links ? .previous ) . toBe ( '' ) ;
254+ expect ( results . links ? .next ) . toBe (
255255 'http://example.com/something?page=2&limit=4' ,
256256 ) ;
257- expect ( results . links . last ) . toBe (
257+ expect ( results . links ? .last ) . toBe (
258258 'http://example.com/something?page=3&limit=4' ,
259259 ) ;
260260 expect ( consoleMock ) . toHaveBeenCalledWith (
@@ -276,12 +276,12 @@ describe('Test paginate function', () => {
276276 } ) ;
277277
278278 expect ( results . items . length ) . toBe ( 4 ) ;
279- expect ( results . links . first ) . toBe ( 'http://example.com/something?limit=4' ) ;
280- expect ( results . links . previous ) . toBe ( '' ) ;
281- expect ( results . links . next ) . toBe (
279+ expect ( results . links ? .first ) . toBe ( 'http://example.com/something?limit=4' ) ;
280+ expect ( results . links ? .previous ) . toBe ( '' ) ;
281+ expect ( results . links ? .next ) . toBe (
282282 'http://example.com/something?page=2&limit=4' ,
283283 ) ;
284- expect ( results . links . last ) . toBe (
284+ expect ( results . links ? .last ) . toBe (
285285 'http://example.com/something?page=3&limit=4' ,
286286 ) ;
287287 expect ( consoleMock ) . toHaveBeenCalledWith (
@@ -303,12 +303,12 @@ describe('Test paginate function', () => {
303303 } ) ;
304304
305305 expect ( results . items . length ) . toBe ( 4 ) ;
306- expect ( results . links . first ) . toBe ( 'http://example.com/something?limit=4' ) ;
307- expect ( results . links . previous ) . toBe ( '' ) ;
308- expect ( results . links . next ) . toBe (
306+ expect ( results . links ? .first ) . toBe ( 'http://example.com/something?limit=4' ) ;
307+ expect ( results . links ? .previous ) . toBe ( '' ) ;
308+ expect ( results . links ? .next ) . toBe (
309309 'http://example.com/something?page=2&limit=4' ,
310310 ) ;
311- expect ( results . links . last ) . toBe (
311+ expect ( results . links ? .last ) . toBe (
312312 'http://example.com/something?page=3&limit=4' ,
313313 ) ;
314314 expect ( consoleMock ) . toHaveBeenCalledWith (
@@ -375,7 +375,7 @@ describe('Test paginate function', () => {
375375 route : '/test?test=test' ,
376376 } ) ;
377377
378- expect ( results . links . next ) . toBe ( '/test?test=test&page=2&limit=4' ) ;
378+ expect ( results . links ? .next ) . toBe ( '/test?test=test&page=2&limit=4' ) ;
379379 } ) ;
380380
381381 it ( 'when page is 0, return empty pagination object' , async ( ) => {
@@ -388,10 +388,10 @@ describe('Test paginate function', () => {
388388 } ) ;
389389
390390 expect ( results . items . length ) . toBe ( 0 ) ;
391- expect ( results . links . first ) . toBe ( '/test?test=test&limit=4' ) ;
392- expect ( results . links . previous ) . toBe ( '' ) ;
393- expect ( results . links . next ) . toBe ( '' ) ;
394- expect ( results . links . last ) . toBe ( '' ) ;
391+ expect ( results . links ? .first ) . toBe ( '/test?test=test&limit=4' ) ;
392+ expect ( results . links ? .previous ) . toBe ( '' ) ;
393+ expect ( results . links ? .next ) . toBe ( '' ) ;
394+ expect ( results . links ? .last ) . toBe ( '' ) ;
395395 } ) ;
396396
397397 it ( 'Can use skip and take' , async ( ) => {
@@ -405,10 +405,10 @@ describe('Test paginate function', () => {
405405 } ) ;
406406
407407 expect ( results . items . length ) . toBe ( 0 ) ;
408- expect ( results . links . first ) . toBe ( '/test?test=test&limit=4' ) ;
409- expect ( results . links . previous ) . toBe ( '' ) ;
410- expect ( results . links . next ) . toBe ( '' ) ;
411- expect ( results . links . last ) . toBe ( '' ) ;
408+ expect ( results . links ? .first ) . toBe ( '/test?test=test&limit=4' ) ;
409+ expect ( results . links ? .previous ) . toBe ( '' ) ;
410+ expect ( results . links ? .next ) . toBe ( '' ) ;
411+ expect ( results . links ? .last ) . toBe ( '' ) ;
412412 } ) ;
413413
414414 it ( 'Can call paginate with no count queries' , async ( ) => {
0 commit comments