@@ -32,7 +32,8 @@ describe('Tasks', function () {
32
32
startedOn : 4567 ,
33
33
status : 'active' ,
34
34
percentCompleted : 10 ,
35
- participants : [ appOwner . username ] ,
35
+ participants : [ ] ,
36
+ assignee : appOwner . username ,
36
37
completionAward : { [ DINERO ] : 3 , [ NEELAM ] : 300 } ,
37
38
lossRate : { [ DINERO ] : 1 } ,
38
39
isNoteworthy : true
@@ -115,7 +116,13 @@ describe('Tasks', function () {
115
116
expect ( res . body . message ) . to . equal ( 'Tasks returned successfully!' )
116
117
expect ( res . body . tasks ) . to . be . a ( 'array' )
117
118
const taskWithParticipants = res . body . tasks [ 0 ]
118
- expect ( taskWithParticipants . participants ) . to . have . members ( [ appOwner . username ] )
119
+
120
+ if ( taskWithParticipants . type === 'group' ) {
121
+ expect ( taskWithParticipants . participants ) . to . include ( appOwner . username )
122
+ } else {
123
+ expect ( taskWithParticipants . assignee ) . to . equal ( appOwner . username )
124
+ }
125
+
119
126
return done ( )
120
127
} )
121
128
} )
@@ -254,12 +261,21 @@ describe('Tasks', function () {
254
261
it ( 'Should return 200 when username is valid' , function ( done ) {
255
262
chai
256
263
. request ( app )
257
- . get ( ' /tasks/sagar' )
264
+ . get ( ` /tasks/${ appOwner . username } ` )
258
265
. end ( ( err , res ) => {
259
266
if ( err ) { return done ( err ) }
260
267
expect ( res ) . to . have . status ( 200 )
261
268
expect ( res . body ) . to . be . a ( 'object' )
262
269
expect ( res . body . message ) . to . equal ( 'Tasks returned successfully!' )
270
+
271
+ const task1 = res . body . tasks [ 0 ]
272
+
273
+ if ( task1 . type === 'group' ) {
274
+ expect ( task1 . participants ) . to . include ( appOwner . username )
275
+ } else {
276
+ expect ( task1 . assignee ) . to . equal ( appOwner . username )
277
+ }
278
+
263
279
expect ( res . body . tasks ) . to . be . a ( 'array' )
264
280
return done ( )
265
281
} )
0 commit comments