@@ -13,6 +13,12 @@ describe('Server', function() {
1313 { id : 2 , body : 'bar' }
1414 ]
1515
16+ low . db . tags = [
17+ { id : 1 , body : 'Technology' } ,
18+ { id : 2 , body : 'Photography' } ,
19+ { id : 3 , body : 'photo' }
20+ ]
21+
1622 low . db . comments = [
1723 { id : 1 , published : true , postId : 1 } ,
1824 { id : 2 , published : false , postId : 1 } ,
@@ -55,6 +61,32 @@ describe('Server', function() {
5561 } )
5662 } )
5763
64+ describe ( 'GET /:resource?q=value' , function ( ) {
65+ it ( 'should respond with json and filter all begin of fields of resources' , function ( done ) {
66+ request ( server )
67+ . get ( '/tags?q=photo' )
68+ . expect ( 'Content-Type' , / j s o n / )
69+ . expect ( [ low . db . tags [ 1 ] , low . db . tags [ 2 ] ] )
70+ . expect ( 200 , done )
71+ } )
72+
73+ it ( 'should respond with json and filter everywhere of all fields of resources' , function ( done ) {
74+ request ( server )
75+ . get ( '/tags?q=t' )
76+ . expect ( 'Content-Type' , / j s o n / )
77+ . expect ( low . db . tags )
78+ . expect ( 200 , done )
79+ } )
80+
81+ it ( 'should not respond anything when the query does not many any data' , function ( done ) {
82+ request ( server )
83+ . get ( '/tags?q=nope' )
84+ . expect ( 'Content-Type' , / j s o n / )
85+ . expect ( [ ] )
86+ . expect ( 200 , done )
87+ } )
88+ } )
89+
5890 describe ( 'GET /:resource?_start=&_end=' , function ( ) {
5991 it ( 'should respond with sliced array' , function ( done ) {
6092 request ( server )
@@ -171,4 +203,4 @@ describe('Server', function() {
171203 } ) ;
172204
173205 } )
174- } )
206+ } )
0 commit comments