Skip to content

Commit

Permalink
Add sorting test
Browse files Browse the repository at this point in the history
  • Loading branch information
manuquentin committed Sep 23, 2014
1 parent 8241655 commit 05bf46e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
it('should respond with a sliced array', function(done) {
request(server)
Expand Down

0 comments on commit 05bf46e

Please sign in to comment.