Update pagination (#346)

This commit is contained in:
typicode
2016-08-28 00:45:56 +02:00
committed by GitHub
parent 95f1dc3b4f
commit 61de2d86c8
4 changed files with 136 additions and 3 deletions

View File

@ -270,8 +270,17 @@ describe('Server', function () {
it('should paginate with a custom limit', function (done) {
request(server)
.get('/list?_page=2&_limit=1')
.set('host', 'localhost')
.expect('Content-Type', /json/)
.expect('x-total-count', db.list.length.toString())
.expect('link',
[
'<http://localhost/list?_page=1&_limit=1>; rel="first"',
'<http://localhost/list?_page=1&_limit=1>; rel="prev"',
'<http://localhost/list?_page=3&_limit=1>; rel="next"',
'<http://localhost/list?_page=15&_limit=1>; rel="last"'
].join(', ')
)
.expect('Access-Control-Expose-Headers', 'X-Total-Count')
.expect(db.list.slice(1, 2))
.expect(200, done)