@@ -80,7 +80,7 @@ describe("syncSpecsLogs", () => {
8080
8181 it ( 'should return proper request option for polling' , ( ) => {
8282 let options = getOptions ( auth , build_id ) ;
83- expect ( options . url ) . to . equal ( `${ config . buildUrl } ${ build_id } ` ) ;
83+ expect ( options . url ) . to . equal ( `${ config . buildUrlV2 } ${ build_id } ` ) ;
8484 expect ( options . auth . user ) . to . equal ( auth . username ) ;
8585 expect ( options . auth . password ) . to . equal ( auth . access_key ) ;
8686 expect ( options . headers [ "Content-Type" ] ) . to . equal ( "application/json" ) ;
@@ -93,6 +93,8 @@ describe("syncSpecsLogs", () => {
9393 "buildError" : null ,
9494 "specs" : [ ] ,
9595 "duration" : null ,
96+ "parallels" : null ,
97+ "cliDuration" : null ,
9698 "customErrorsToPrint" : [
9799 { id : "custom_error_1" , type : "custom_errors_to_print" , level : "warn" , should_be_unique : true , message : "custom error message" }
98100 ]
@@ -216,35 +218,38 @@ describe("syncSpecsLogs", () => {
216218
217219 context ( "showSpecsStatus" , ( ) => {
218220 const showSpecsStatus = syncSpecsLogs . __get__ ( "showSpecsStatus" ) ;
221+ const buildCreatedStatusCode = 202
222+ const buildRunningStatusCode = 204
223+ const buildCompletedStatusCode = 200
219224
220225 it ( 'should not print initial log for running specs when it is the 1st polling response' , ( ) => {
221- let data = JSON . stringify ( [ "created" ] )
226+ let data = JSON . stringify ( { "specData" : [ "created" ] , "buildData" : { "duration" : "NA" , "parallels" : "NA" } } )
222227 var printInitialLog = sandbox . stub ( ) ;
223228 syncSpecsLogs . __set__ ( 'printInitialLog' , printInitialLog ) ;
224229
225- showSpecsStatus ( data ) ;
230+ showSpecsStatus ( data , buildCreatedStatusCode ) ;
226231
227232 expect ( printInitialLog . calledOnce ) . to . be . false ;
228233 } ) ;
229234
230235 it ( 'should print spec details when spec related data is sent in polling response' , ( ) => {
231236 let specResult = JSON . stringify ( { "path" : "path" } )
232- let data = JSON . stringify ( [ specResult ] )
237+ let data = JSON . stringify ( { "specData" : [ specResult ] , "buildData" : { "duration" : "NA" , "parallels" : "NA" } } )
233238 var printSpecData = sandbox . stub ( ) ;
234239 syncSpecsLogs . __set__ ( 'printSpecData' , printSpecData ) ;
235- showSpecsStatus ( data ) ;
240+ showSpecsStatus ( data , buildRunningStatusCode ) ;
236241 expect ( printSpecData . calledOnce ) . to . be . true ;
237242 } ) ;
238243
239244 it ( 'should print initial and spec details when spec related data is sent in polling response' , ( ) => {
240245 let specResult = JSON . stringify ( { "path" : "path" } )
241246 syncSpecsLogs . __set__ ( 'buildStarted' , false )
242- let data = JSON . stringify ( [ "created" , specResult ] )
247+ let data = JSON . stringify ( { "specData" : [ specResult ] , "buildData" : { "duration" : "NA" , "parallels" : "NA" } } )
243248 var printSpecData = sandbox . stub ( ) ;
244249 syncSpecsLogs . __set__ ( 'printSpecData' , printSpecData ) ;
245250 var printInitialLog = sandbox . stub ( ) ;
246251 syncSpecsLogs . __set__ ( 'printInitialLog' , printInitialLog ) ;
247- showSpecsStatus ( data ) ;
252+ showSpecsStatus ( data , buildCreatedStatusCode ) ;
248253 expect ( printSpecData . calledOnce ) . to . be . true ;
249254 expect ( printInitialLog . calledOnce ) . to . be . true ;
250255 } ) ;
@@ -253,14 +258,14 @@ describe("syncSpecsLogs", () => {
253258 let specResult = JSON . stringify ( { "path" : "path" } )
254259 let customError = { id : "custom_error_1" , type : "custom_errors_to_print" , level : "warn" , should_be_unique : true , message : "custom error message" }
255260 syncSpecsLogs . __set__ ( 'buildStarted' , false )
256- let data = JSON . stringify ( [ "created" , specResult , customError ] )
261+ let data = JSON . stringify ( { "specData" : [ "created" , specResult , customError ] , "buildData" : { "duration" : "NA" , "parallels" : "NA" } } )
257262 var printSpecData = sandbox . stub ( ) ;
258263 syncSpecsLogs . __set__ ( 'printSpecData' , printSpecData ) ;
259264 var printInitialLog = sandbox . stub ( ) ;
260265 syncSpecsLogs . __set__ ( 'printInitialLog' , printInitialLog ) ;
261266 var addCustomErrorToPrint = sandbox . stub ( ) ;
262267 syncSpecsLogs . __set__ ( 'addCustomErrorToPrint' , addCustomErrorToPrint ) ;
263- showSpecsStatus ( data ) ;
268+ showSpecsStatus ( data , buildRunningStatusCode ) ;
264269 expect ( printSpecData . calledOnce ) . to . be . true ;
265270 expect ( printInitialLog . calledOnce ) . to . be . true ;
266271 expect ( addCustomErrorToPrint . calledOnce ) . to . be . true ;
@@ -307,7 +312,7 @@ describe("syncSpecsLogs", () => {
307312 expect ( tableStream . calledOnce ) . to . be . true ;
308313 expect ( whileProcess . calledOnce ) . to . be . false ;
309314 expect ( specSummary . specs ) . deep . to . equal ( [ ] )
310- expect ( specSummary . duration ) . to . eql ( endTime - startTime ) ;
315+ expect ( specSummary . cliDuration ) . to . eql ( endTime - startTime ) ;
311316 } ) ;
312317 } ) ;
313318
@@ -322,7 +327,7 @@ describe("syncSpecsLogs", () => {
322327 expect ( getTableConfig . calledOnce ) . to . be . true ;
323328 expect ( tableStream . calledOnce ) . to . be . true ;
324329 expect ( whileProcess . callCount ) . to . eql ( 3 ) ;
325- expect ( specSummary . duration ) . to . eql ( endTime - startTime ) ;
330+ expect ( specSummary . cliDuration ) . to . eql ( endTime - startTime ) ;
326331 } ) ;
327332 } ) ;
328333 } ) ;
0 commit comments