@@ -87,6 +87,42 @@ describe("syncSpecsLogs", () => {
87
87
} ) ;
88
88
} ) ;
89
89
90
+ context ( "addCustomErrorToPrint" , ( ) => {
91
+ const addCustomErrorToPrint = syncSpecsLogs . __get__ ( "addCustomErrorToPrint" ) ;
92
+ let specSummary = {
93
+ "buildError" : null ,
94
+ "specs" : [ ] ,
95
+ "duration" : null ,
96
+ "customErrorsToPrint" : [
97
+ { id : "custom_error_1" , type : "custom_errors_to_print" , level : "warn" , should_be_unique : true , message : "custom error message" }
98
+ ]
99
+ }
100
+ const uniqueError = { id : "custom_error_1" , type : "custom_errors_to_print" , level : "warn" , should_be_unique : true , message : "custom error message" } ;
101
+ const notUniqueError = { id : "custom_error_2" , type : "custom_errors_to_print" , level : "warn" , should_be_unique : false , message : "custom error message" } ;
102
+
103
+ it ( 'should add a new Error if its meant to be unique and not added to the error list' , ( ) => {
104
+ addCustomErrorToPrint ( uniqueError ) ;
105
+ expect ( JSON . stringify ( syncSpecsLogs . __get__ ( "specSummary" ) ) ) . to . equal ( JSON . stringify ( specSummary ) ) ;
106
+ } ) ;
107
+
108
+ it ( 'should not add a new Error if its meant to be unique and already added to the error list' , ( ) => {
109
+ addCustomErrorToPrint ( uniqueError ) ;
110
+ expect ( JSON . stringify ( syncSpecsLogs . __get__ ( "specSummary" ) ) ) . to . equal ( JSON . stringify ( specSummary ) ) ;
111
+ } ) ;
112
+
113
+ it ( 'should add a new Error if its not meant to be unique and not added to the error list' , ( ) => {
114
+ addCustomErrorToPrint ( notUniqueError ) ;
115
+ specSummary . customErrorsToPrint . push ( notUniqueError ) ;
116
+ expect ( JSON . stringify ( syncSpecsLogs . __get__ ( "specSummary" ) ) ) . to . equal ( JSON . stringify ( specSummary ) ) ;
117
+ } ) ;
118
+
119
+ it ( 'should not add a new Error if its not meant to not be unique and already added to the error list' , ( ) => {
120
+ addCustomErrorToPrint ( notUniqueError ) ;
121
+ specSummary . customErrorsToPrint . push ( notUniqueError ) ;
122
+ expect ( JSON . stringify ( syncSpecsLogs . __get__ ( "specSummary" ) ) ) . to . equal ( JSON . stringify ( specSummary ) ) ;
123
+ } ) ;
124
+ } ) ;
125
+
90
126
context ( "getTableConfig" , ( ) => {
91
127
const getTableConfig = syncSpecsLogs . __get__ ( "getTableConfig" ) ;
92
128
@@ -212,6 +248,23 @@ describe("syncSpecsLogs", () => {
212
248
expect ( printSpecData . calledOnce ) . to . be . true ;
213
249
expect ( printInitialLog . calledOnce ) . to . be . true ;
214
250
} ) ;
251
+
252
+ it ( 'should add custom error, print initial and spec details when spec related data is sent in polling response' , ( ) => {
253
+ let specResult = JSON . stringify ( { "path" : "path" } )
254
+ let customError = { id : "custom_error_1" , type : "custom_errors_to_print" , level : "warn" , should_be_unique : true , message : "custom error message" }
255
+ syncSpecsLogs . __set__ ( 'buildStarted' , false )
256
+ let data = JSON . stringify ( [ "created" , specResult , customError ] )
257
+ var printSpecData = sandbox . stub ( ) ;
258
+ syncSpecsLogs . __set__ ( 'printSpecData' , printSpecData ) ;
259
+ var printInitialLog = sandbox . stub ( ) ;
260
+ syncSpecsLogs . __set__ ( 'printInitialLog' , printInitialLog ) ;
261
+ var addCustomErrorToPrint = sandbox . stub ( ) ;
262
+ syncSpecsLogs . __set__ ( 'addCustomErrorToPrint' , addCustomErrorToPrint ) ;
263
+ showSpecsStatus ( data ) ;
264
+ expect ( printSpecData . calledOnce ) . to . be . true ;
265
+ expect ( printInitialLog . calledOnce ) . to . be . true ;
266
+ expect ( addCustomErrorToPrint . calledOnce ) . to . be . true ;
267
+ } ) ;
215
268
} ) ;
216
269
217
270
context ( "printSpecsStatus" , ( ) => {
0 commit comments