File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,6 @@ const getBuiltTasks = async (tasksSnapshot, searchTerm) => {
104
104
if ( searchTerm ) {
105
105
updatedTasks = updatedTasks . filter ( ( task ) => task . title . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) ) ;
106
106
}
107
-
108
107
const taskPromises = updatedTasks . map ( async ( task ) => {
109
108
task . status = TASK_STATUS [ task . status . toUpperCase ( ) ] || task . status ;
110
109
const taskId = task . id ;
Original file line number Diff line number Diff line change @@ -264,6 +264,29 @@ describe("Tasks", function () {
264
264
} ) ;
265
265
266
266
describe ( "GET /tasks/:id/details" , function ( ) {
267
+ it ( "Should get tasks filtered by search term" , function ( done ) {
268
+ const searchTerm = "search" ;
269
+ chai
270
+ . request ( app )
271
+ . get ( `/tasks?q=${ encodeURIComponent ( searchTerm ) } ` )
272
+ . end ( ( err , res ) => {
273
+ if ( err ) {
274
+ return done ( err ) ;
275
+ }
276
+
277
+ expect ( res ) . to . have . status ( 200 ) ;
278
+ expect ( res . body ) . to . be . a ( "object" ) ;
279
+ expect ( res . body . message ) . to . equal ( "Filter tasks returned successfully!" ) ;
280
+ expect ( res . body . tasks ) . to . be . a ( "array" ) ;
281
+
282
+ const matchingTasks = res . body . tasks ;
283
+ matchingTasks . forEach ( ( task ) => {
284
+ expect ( task . title . toLowerCase ( ) ) . to . include ( searchTerm . toLowerCase ( ) ) ;
285
+ } ) ;
286
+
287
+ return done ( ) ;
288
+ } ) ;
289
+ } ) ;
267
290
it ( "should return the task task with the Id that we provide in the route params" , function ( done ) {
268
291
chai
269
292
. request ( app )
You can’t perform that action at this time.
0 commit comments