@@ -46,7 +46,11 @@ describe('configFromJobInput()', function () {
46
46
'max-items-in-chart' : '' ,
47
47
} ;
48
48
49
- const validation_tests = [
49
+ const validationTests : Array < {
50
+ what : string ;
51
+ inputs : Inputs ;
52
+ expected : RegExp ;
53
+ } > = [
50
54
{
51
55
what : 'wrong name' ,
52
56
inputs : { ...defaultInputs , name : '' } ,
@@ -158,18 +162,12 @@ describe('configFromJobInput()', function () {
158
162
inputs : { ...defaultInputs , 'alert-threshold' : '150%' , 'fail-threshold' : '120%' } ,
159
163
expected : / ' a l e r t - t h r e s h o l d ' v a l u e m u s t b e s m a l l e r t h a n ' f a i l - t h r e s h o l d ' v a l u e b u t g o t 1 .5 > 1 .2 / ,
160
164
} ,
161
- ] as Array < {
162
- what : string ;
163
- inputs : Inputs ;
164
- expected : RegExp ;
165
- } > ;
165
+ ] ;
166
166
167
- for ( const test of validation_tests ) {
168
- it ( `validates ${ test . what } ` , async function ( ) {
169
- mockInputs ( test . inputs ) ;
170
- await A . rejects ( configFromJobInput , test . expected ) ;
171
- } ) ;
172
- }
167
+ it . each ( validationTests ) ( 'validates $what' , async function ( test ) {
168
+ mockInputs ( test . inputs ) ;
169
+ await A . rejects ( configFromJobInput , test . expected ) ;
170
+ } ) ;
173
171
174
172
interface ExpectedResult {
175
173
name : string ;
@@ -205,7 +203,11 @@ describe('configFromJobInput()', function () {
205
203
failThreshold : null ,
206
204
} ;
207
205
208
- const returnedConfigTests = [
206
+ const returnedConfigTests : Array < {
207
+ what : string ;
208
+ inputs : any ;
209
+ expected : ExpectedResult ;
210
+ } > = [
209
211
...VALID_TOOLS . map ( ( tool : string ) => ( {
210
212
what : 'valid tool ' + tool ,
211
213
inputs : { ...defaultInputs , tool } ,
@@ -237,20 +239,24 @@ describe('configFromJobInput()', function () {
237
239
inputs : { ...defaultInputs , 'gh-pages-branch' : 'master' } ,
238
240
expected : { ...defaultExpected , ghPagesBranch : 'master' } ,
239
241
} ,
240
- ...[
241
- [ '150%' , 1.5 ] ,
242
- [ '0%' , 0 ] ,
243
- [ '123.4%' , 1.234 ] ,
244
- ] . map ( ( [ v , e ] ) => ( {
242
+ ...(
243
+ [
244
+ [ '150%' , 1.5 ] ,
245
+ [ '0%' , 0 ] ,
246
+ [ '123.4%' , 1.234 ] ,
247
+ ] as Array < [ string , number ] >
248
+ ) . map ( ( [ v , e ] ) => ( {
245
249
what : `with alert threshold ${ v } ` ,
246
250
inputs : { ...defaultInputs , 'alert-threshold' : v } ,
247
251
expected : { ...defaultExpected , alertThreshold : e } ,
248
252
} ) ) ,
249
- ...[
250
- [ '@foo' , [ '@foo' ] ] ,
251
- [ '@foo,@bar' , [ '@foo' , '@bar' ] ] ,
252
- [ '@foo, @bar ' , [ '@foo' , '@bar' ] ] ,
253
- ] . map ( ( [ v , e ] ) => ( {
253
+ ...(
254
+ [
255
+ [ '@foo' , [ '@foo' ] ] ,
256
+ [ '@foo,@bar' , [ '@foo' , '@bar' ] ] ,
257
+ [ '@foo, @bar ' , [ '@foo' , '@bar' ] ] ,
258
+ ] as Array < [ string , string [ ] ] >
259
+ ) . map ( ( [ v , e ] ) => ( {
254
260
what : `with comment CC users ${ v } ` ,
255
261
inputs : { ...defaultInputs , 'alert-comment-cc-users' : v } ,
256
262
expected : { ...defaultExpected , alertCommentCcUsers : e } ,
@@ -280,42 +286,36 @@ describe('configFromJobInput()', function () {
280
286
} ,
281
287
expected : defaultExpected ,
282
288
} ,
283
- ] as Array < {
284
- what : string ;
285
- inputs : Inputs ;
286
- expected : ExpectedResult ;
287
- } > ;
289
+ ] ;
288
290
289
- for ( const test of returnedConfigTests ) {
290
- it ( `returns validated config with ${ test . what } ` , async function ( ) {
291
- mockInputs ( test . inputs ) ;
292
- const actual = await configFromJobInput ( ) ;
293
- A . equal ( actual . name , test . expected . name ) ;
294
- A . equal ( actual . tool , test . expected . tool ) ;
295
- A . equal ( actual . ghPagesBranch , test . expected . ghPagesBranch ) ;
296
- A . equal ( actual . githubToken , test . expected . githubToken ) ;
297
- A . equal ( actual . skipFetchGhPages , test . expected . skipFetchGhPages ) ;
298
- A . equal ( actual . commentOnAlert , test . expected . commentOnAlert ) ;
299
- A . equal ( actual . failOnAlert , test . expected . failOnAlert ) ;
300
- A . equal ( actual . alertThreshold , test . expected . alertThreshold ) ;
301
- A . deepEqual ( actual . alertCommentCcUsers , test . expected . alertCommentCcUsers ) ;
302
- A . ok ( path . isAbsolute ( actual . outputFilePath ) , actual . outputFilePath ) ;
303
- A . ok ( path . isAbsolute ( actual . benchmarkDataDirPath ) , actual . benchmarkDataDirPath ) ;
304
- A . equal ( actual . maxItemsInChart , test . expected . maxItemsInChart ) ;
305
- if ( test . expected . failThreshold === null ) {
306
- A . equal ( actual . failThreshold , test . expected . alertThreshold ) ;
307
- } else {
308
- A . equal ( actual . failThreshold , test . expected . failThreshold ) ;
309
- }
291
+ it . each ( returnedConfigTests ) ( 'returns validated config with $what' , async function ( test ) {
292
+ mockInputs ( test . inputs ) ;
293
+ const actual = await configFromJobInput ( ) ;
294
+ A . equal ( actual . name , test . expected . name ) ;
295
+ A . equal ( actual . tool , test . expected . tool ) ;
296
+ A . equal ( actual . ghPagesBranch , test . expected . ghPagesBranch ) ;
297
+ A . equal ( actual . githubToken , test . expected . githubToken ) ;
298
+ A . equal ( actual . skipFetchGhPages , test . expected . skipFetchGhPages ) ;
299
+ A . equal ( actual . commentOnAlert , test . expected . commentOnAlert ) ;
300
+ A . equal ( actual . failOnAlert , test . expected . failOnAlert ) ;
301
+ A . equal ( actual . alertThreshold , test . expected . alertThreshold ) ;
302
+ A . deepEqual ( actual . alertCommentCcUsers , test . expected . alertCommentCcUsers ) ;
303
+ A . ok ( path . isAbsolute ( actual . outputFilePath ) , actual . outputFilePath ) ;
304
+ A . ok ( path . isAbsolute ( actual . benchmarkDataDirPath ) , actual . benchmarkDataDirPath ) ;
305
+ A . equal ( actual . maxItemsInChart , test . expected . maxItemsInChart ) ;
306
+ if ( test . expected . failThreshold === null ) {
307
+ A . equal ( actual . failThreshold , test . expected . alertThreshold ) ;
308
+ } else {
309
+ A . equal ( actual . failThreshold , test . expected . failThreshold ) ;
310
+ }
310
311
311
- if ( test . expected . hasExternalDataJsonPath ) {
312
- A . equal ( typeof actual . externalDataJsonPath , 'string' ) ;
313
- A . ok ( path . isAbsolute ( actual . externalDataJsonPath as string ) , actual . externalDataJsonPath ) ;
314
- } else {
315
- A . equal ( actual . externalDataJsonPath , undefined ) ;
316
- }
317
- } ) ;
318
- }
312
+ if ( test . expected . hasExternalDataJsonPath ) {
313
+ A . equal ( typeof actual . externalDataJsonPath , 'string' ) ;
314
+ A . ok ( path . isAbsolute ( actual . externalDataJsonPath as string ) , actual . externalDataJsonPath ) ;
315
+ } else {
316
+ A . equal ( actual . externalDataJsonPath , undefined ) ;
317
+ }
318
+ } ) ;
319
319
320
320
it ( 'resolves relative paths in config' , async function ( ) {
321
321
mockInputs ( {
0 commit comments