@@ -20,7 +20,11 @@ describe('LIST Project', () => {
2020 name : 'test1' ,
2121 description : 'test project1' ,
2222 status : 'active' ,
23- details : { } ,
23+ details : {
24+ utm : {
25+ code : 'code1'
26+ }
27+ } ,
2428 createdBy : 1 ,
2529 updatedBy : 1
2630 } ) . then ( p => {
@@ -175,6 +179,84 @@ describe('LIST Project', () => {
175179 done ( )
176180 } )
177181 } )
178- } )
179182
183+ it ( 'should return all projects that match when filtering by name' , done => {
184+ request ( server )
185+ . get ( '/v4/projects/?filter=keyword%3Dtest' )
186+ . set ( {
187+ 'Authorization' : 'Bearer ' + testUtil . jwts . admin
188+ } )
189+ . expect ( 'Content-Type' , / j s o n / )
190+ . expect ( 200 )
191+ . end ( function ( err , res ) {
192+ if ( err ) {
193+ return done ( err )
194+ }
195+ var resJson = res . body . result . content
196+ should . exist ( resJson )
197+ resJson . should . have . lengthOf ( 3 )
198+ done ( )
199+ } )
200+ } )
201+
202+ it ( 'should return the project when filtering by keyword, which matches the name' , done => {
203+ request ( server )
204+ . get ( '/v4/projects/?filter=keyword%3D1' )
205+ . set ( {
206+ 'Authorization' : 'Bearer ' + testUtil . jwts . admin
207+ } )
208+ . expect ( 'Content-Type' , / j s o n / )
209+ . expect ( 200 )
210+ . end ( function ( err , res ) {
211+ if ( err ) {
212+ return done ( err )
213+ }
214+ var resJson = res . body . result . content
215+ should . exist ( resJson )
216+ resJson . should . have . lengthOf ( 1 )
217+ resJson [ 0 ] . name . should . equal ( 'test1' )
218+ done ( )
219+ } )
220+ } )
221+
222+ it ( 'should return the project when filtering by keyword, which matches the description' , done => {
223+ request ( server )
224+ . get ( '/v4/projects/?filter=keyword%3Dproject' )
225+ . set ( {
226+ 'Authorization' : 'Bearer ' + testUtil . jwts . admin
227+ } )
228+ . expect ( 'Content-Type' , / j s o n / )
229+ . expect ( 200 )
230+ . end ( function ( err , res ) {
231+ if ( err ) {
232+ return done ( err )
233+ }
234+ var resJson = res . body . result . content
235+ should . exist ( resJson )
236+ resJson . should . have . lengthOf ( 3 )
237+ done ( )
238+ } )
239+ } )
240+
241+ it ( 'should return the project when filtering by keyword, which matches the details' , done => {
242+ request ( server )
243+ . get ( '/v4/projects/?filter=keyword%3Dcode' )
244+ . set ( {
245+ 'Authorization' : 'Bearer ' + testUtil . jwts . admin
246+ } )
247+ . expect ( 'Content-Type' , / j s o n / )
248+ . expect ( 200 )
249+ . end ( function ( err , res ) {
250+ if ( err ) {
251+ return done ( err )
252+ }
253+ var resJson = res . body . result . content
254+ should . exist ( resJson )
255+ resJson . should . have . lengthOf ( 1 )
256+ resJson [ 0 ] . name . should . equal ( 'test1' )
257+ done ( )
258+ } )
259+ } )
260+ } )
261+
180262} )
0 commit comments