@@ -112,13 +112,48 @@ describe("Tasks", function () {
112
112
expect ( res . body . message ) . to . equal ( "Task created successfully!" ) ;
113
113
expect ( res . body . task ) . to . be . a ( "object" ) ;
114
114
expect ( res . body . task . id ) . to . be . a ( "string" ) ;
115
+ expect ( res . body . task . createdAt ) . to . be . a ( "number" ) ;
116
+ expect ( res . body . task . updatedAt ) . to . be . a ( "number" ) ;
115
117
expect ( res . body . task . createdBy ) . to . equal ( appOwner . username ) ;
116
118
expect ( res . body . task . assignee ) . to . equal ( appOwner . username ) ;
117
119
expect ( res . body . task . participants ) . to . be . a ( "array" ) ;
118
120
expect ( res . body . task . dependsOn ) . to . be . a ( "array" ) ;
119
121
return done ( ) ;
120
122
} ) ;
121
123
} ) ;
124
+ it ( "Should have same time for createdAt and updatedAt for new tasks" , function ( done ) {
125
+ chai
126
+ . request ( app )
127
+ . post ( "/tasks" )
128
+ . set ( "cookie" , `${ cookieName } =${ jwt } ` )
129
+ . send ( {
130
+ title : "Test task - Create" ,
131
+ type : "feature" ,
132
+ endsOn : 123 ,
133
+ startedOn : 456 ,
134
+ status : "AVAILABLE" ,
135
+ percentCompleted : 10 ,
136
+ priority : "HIGH" ,
137
+ completionAward : { [ DINERO ] : 3 , [ NEELAM ] : 300 } ,
138
+ lossRate : { [ DINERO ] : 1 } ,
139
+ assignee : appOwner . username ,
140
+ participants : [ ] ,
141
+ dependsOn : [ ] ,
142
+ } )
143
+ . end ( ( err , res ) => {
144
+ if ( err ) {
145
+ return done ( err ) ;
146
+ }
147
+ expect ( res ) . to . have . status ( 200 ) ;
148
+ expect ( res . body ) . to . be . a ( "object" ) ;
149
+ expect ( res . body . message ) . to . equal ( "Task created successfully!" ) ;
150
+ expect ( res . body . task ) . to . be . a ( "object" ) ;
151
+ expect ( res . body . task . createdAt ) . to . be . a ( "number" ) ;
152
+ expect ( res . body . task . updatedAt ) . to . be . a ( "number" ) ;
153
+ expect ( res . body . task . createdAt ) . to . be . eq ( res . body . task . updatedAt ) ;
154
+ return done ( ) ;
155
+ } ) ;
156
+ } ) ;
122
157
it ( "should return fail response if task has a non-acceptable status value" , function ( done ) {
123
158
chai
124
159
. request ( app )
@@ -374,7 +409,7 @@ describe("Tasks", function () {
374
409
matchingTasks . forEach ( ( task ) => {
375
410
expect ( task . title . toLowerCase ( ) ) . to . include ( searchTerm . toLowerCase ( ) ) ;
376
411
} ) ;
377
- expect ( matchingTasks ) . to . have . length ( 3 ) ;
412
+ expect ( matchingTasks ) . to . have . length ( 4 ) ;
378
413
379
414
return done ( ) ;
380
415
} ) ;
@@ -535,7 +570,7 @@ describe("Tasks", function () {
535
570
} ) ;
536
571
537
572
describe ( "PATCH /tasks" , function ( ) {
538
- it ( "Should update the task for the given taskid " , function ( done ) {
573
+ it ( "Should update the task for the given taskId " , function ( done ) {
539
574
chai
540
575
. request ( app )
541
576
. patch ( "/tasks/" + taskId1 )
@@ -551,6 +586,41 @@ describe("Tasks", function () {
551
586
return done ( ) ;
552
587
} ) ;
553
588
} ) ;
589
+
590
+ it ( "should update updatedAt field when patch request is made" , function ( done ) {
591
+ chai
592
+ . request ( app )
593
+ . patch ( "/tasks/" + taskId1 )
594
+ . set ( "cookie" , `${ cookieName } =${ jwt } ` )
595
+ . send ( {
596
+ title : "new-title" ,
597
+ } )
598
+ . end ( ( err , res ) => {
599
+ if ( err ) {
600
+ return done ( err ) ;
601
+ }
602
+ expect ( res ) . to . have . status ( 204 ) ;
603
+ return done ( ) ;
604
+ } ) ;
605
+ } ) ;
606
+
607
+ it ( "should update updatedAt field" , function ( done ) {
608
+ chai
609
+ . request ( app )
610
+ . get ( `/tasks/${ taskId1 } /details` )
611
+ . end ( ( err , res ) => {
612
+ if ( err ) {
613
+ return done ( err ) ;
614
+ }
615
+ expect ( res ) . to . have . status ( 200 ) ;
616
+ expect ( res . body ) . to . be . a ( "object" ) ;
617
+ expect ( res . body . taskData . updatedAt ) . to . be . a ( "number" ) ;
618
+ expect ( res . body . taskData . updatedAt ) . to . be . not . eq ( tasksData [ 0 ] . updatedAt ) ;
619
+ expect ( res . body . taskData . updatedAt ) . to . be . not . eq ( res . body . taskData . createdAt ) ;
620
+ return done ( ) ;
621
+ } ) ;
622
+ } ) ;
623
+
554
624
it ( "Should update dependency" , async function ( ) {
555
625
taskId = ( await tasks . updateTask ( tasksData [ 5 ] ) ) . taskId ;
556
626
const taskId1 = ( await tasks . updateTask ( tasksData [ 5 ] ) ) . taskId ;
0 commit comments