Add global search

This commit is contained in:
Emmanuel Quentin
2014-09-11 08:37:31 +02:00
parent 96f2112231
commit 165b1442e7
2 changed files with 52 additions and 4 deletions

View File

@ -13,6 +13,12 @@ describe('Server', function() {
{id: 2, body: 'bar'}
]
low.db.tags = [
{id: 1, body: 'Technology'},
{id: 2, body: 'Photography'},
{id: 3, body: 'photo'}
]
low.db.comments = [
{id: 1, published: true, postId: 1},
{id: 2, published: false, postId: 1},
@ -55,6 +61,32 @@ describe('Server', function() {
})
})
describe('GET /:resource?q=value', function() {
it('should respond with json and filter all begin of fields of resources', function(done) {
request(server)
.get('/tags?q=photo')
.expect('Content-Type', /json/)
.expect([low.db.tags[1], low.db.tags[2]])
.expect(200, done)
})
it('should respond with json and filter everywhere of all fields of resources', function(done) {
request(server)
.get('/tags?q=t')
.expect('Content-Type', /json/)
.expect(low.db.tags)
.expect(200, done)
})
it('should not respond anything when the query does not many any data', function(done) {
request(server)
.get('/tags?q=nope')
.expect('Content-Type', /json/)
.expect([])
.expect(200, done)
})
})
describe('GET /:resource?_start=&_end=', function() {
it('should respond with sliced array', function(done) {
request(server)
@ -171,4 +203,4 @@ describe('Server', function() {
});
})
})
})