Add sorting test

This commit is contained in:
Emmanuel Quentin
2014-09-18 11:22:44 +02:00
parent 8241655178
commit 05bf46e501

View File

@ -91,6 +91,32 @@ describe('Server', function() {
}) })
}) })
describe('GET /:resource?sort=', function() {
it('should respond with json and sort on a field', function(done) {
request(server)
.get('/tags?_sort=body')
.expect('Content-Type', /json/)
.expect([low.db.tags[1], low.db.tags[0], low.db.tags[2]])
.expect(200, done)
})
it('should reverse sorting with sortDir=DESC', function(done) {
request(server)
.get('/tags?_sort=body&_sortDir=DESC')
.expect('Content-Type', /json/)
.expect([low.db.tags[2], low.db.tags[0], low.db.tags[1]])
.expect(200, done)
})
it('should sort on numerical field', function(done) {
request(server)
.get('/posts?_sort=id&_sortDir=DESC')
.expect('Content-Type', /json/)
.expect(low.db.posts.reverse())
.expect(200, done)
})
})
describe('GET /:resource?_start=&_end=', function() { describe('GET /:resource?_start=&_end=', function() {
it('should respond with a sliced array', function(done) { it('should respond with a sliced array', function(done) {
request(server) request(server)