@@ -5,6 +5,7 @@ import chai from 'chai';
55import request from 'supertest' ;
66import sleep from 'sleep' ;
77import config from 'config' ;
8+ import _ from 'lodash' ;
89
910import models from '../../models' ;
1011import server from '../../app' ;
@@ -58,6 +59,16 @@ const milestones = [
5859 updatedBy : 2 ,
5960 createdAt : '2018-05-11T00:00:00.000Z' ,
6061 updatedAt : '2018-05-11T00:00:00.000Z' ,
62+ statusHistory : [ {
63+ reference : 'milestone' ,
64+ referenceId : '1' ,
65+ status : 'active' ,
66+ comment : 'comment' ,
67+ createdBy : 1 ,
68+ createdAt : '2018-05-15T00:00:00Z' ,
69+ updatedBy : 1 ,
70+ updatedAt : '2018-05-15T00:00:00Z' ,
71+ } ] ,
6172 } ,
6273 {
6374 id : 2 ,
@@ -76,6 +87,16 @@ const milestones = [
7687 updatedBy : 3 ,
7788 createdAt : '2018-05-11T00:00:00.000Z' ,
7889 updatedAt : '2018-05-11T00:00:00.000Z' ,
90+ statusHistory : [ {
91+ reference : 'milestone' ,
92+ referenceId : '2' ,
93+ status : 'active' ,
94+ comment : 'comment' ,
95+ createdBy : 1 ,
96+ createdAt : '2018-05-15T00:00:00Z' ,
97+ updatedBy : 1 ,
98+ updatedAt : '2018-05-15T00:00:00Z' ,
99+ } ] ,
79100 } ,
80101] ;
81102
@@ -165,7 +186,10 @@ describe('LIST timelines', () => {
165186 . then ( ( ) =>
166187 // Create timelines and milestones
167188 models . Timeline . bulkCreate ( timelines )
168- . then ( ( ) => models . Milestone . bulkCreate ( milestones ) ) )
189+ . then ( ( ) => {
190+ const mappedMilstones = milestones . map ( milestone => _ . omit ( milestone , [ 'statusHistory' ] ) ) ;
191+ return models . Milestone . bulkCreate ( mappedMilstones ) ;
192+ } ) )
169193 . then ( ( ) => {
170194 // Index to ES
171195 timelines [ 0 ] . milestones = milestones ;
@@ -242,8 +266,15 @@ describe('LIST timelines', () => {
242266 const resJson = res . body . result . content ;
243267 resJson . should . have . length ( 2 ) ;
244268
245- resJson [ 0 ] . should . be . eql ( milestones [ 0 ] ) ;
246- resJson [ 1 ] . should . be . eql ( milestones [ 1 ] ) ;
269+ resJson . forEach ( ( milestone , index ) => {
270+ milestone . statusHistory . should . be . an ( 'array' ) ;
271+ milestone . statusHistory . forEach ( ( statusHistory ) => {
272+ statusHistory . reference . should . be . eql ( 'milestone' ) ;
273+ statusHistory . referenceId . should . be . eql ( `${ milestone . id } ` ) ;
274+ } ) ;
275+
276+ milestone . should . be . eql ( milestones [ index ] ) ;
277+ } ) ;
247278
248279 done ( ) ;
249280 } ) ;
0 commit comments