@@ -84,6 +84,50 @@ describe('Parse Parameters', () => {
8484 process . env = oldEnv
8585 } )
8686
87+ test ( 'returns parameters empty string' , async ( ) => {
88+ const json = parseParameters ( '' )
89+ expect ( json ) . toEqual ( [ ] )
90+ } )
91+
92+ test ( 'returns parameters empty YAML' , async ( ) => {
93+ const json = parseParameters ( '0' )
94+ expect ( json ) . toEqual ( [ ] )
95+ } )
96+
97+ type CFParameterValue = string | string [ ] | boolean
98+ type CFParameterObject = Record < string , CFParameterValue >
99+
100+ test ( 'handles empty parameter overrides object' , ( ) => {
101+ const parameterOverrides : CFParameterObject = { }
102+ const result = parseParameters ( parameterOverrides )
103+ expect ( result ) . toEqual ( [ ] )
104+ } )
105+
106+ test ( 'handles undefined values in parameter overrides object' , ( ) => {
107+ const parameterOverrides : CFParameterObject = {
108+ ValidParam : 'value' ,
109+ EmptyParam : '' ,
110+ ListParam : [ 'value1' , 'value2' ]
111+ }
112+
113+ const result = parseParameters ( parameterOverrides )
114+
115+ expect ( result ) . toEqual ( [
116+ {
117+ ParameterKey : 'ValidParam' ,
118+ ParameterValue : 'value'
119+ } ,
120+ {
121+ ParameterKey : 'EmptyParam' ,
122+ ParameterValue : ''
123+ } ,
124+ {
125+ ParameterKey : 'ListParam' ,
126+ ParameterValue : 'value1,value2'
127+ }
128+ ] )
129+ } )
130+
87131 test ( 'returns parameters list from string' , async ( ) => {
88132 const json = parseParameters ( 'MyParam1=myValue1,MyParam2=myValue2' )
89133 expect ( json ) . toEqual ( [
@@ -116,7 +160,7 @@ describe('Parse Parameters', () => {
116160
117161 test ( 'returns parameters list with an extra equal' , async ( ) => {
118162 const json = parseParameters (
119- 'MyParam1=myValue1,MyParam2=myValue2=myValue3,MyParam2=myValue4'
163+ 'MyParam1=myValue1,MyParam2=myValue2=myValue3,MyParam2=myValue4 '
120164 )
121165 expect ( json ) . toEqual ( [
122166 {
@@ -177,6 +221,85 @@ describe('Parse Parameters', () => {
177221 ] )
178222 } )
179223
224+ test ( 'returns parameters list from YAML array format' , async ( ) => {
225+ const yaml = `
226+ - ParameterKey: MyParam1
227+ ParameterValue: myValue1
228+ - ParameterKey: MyParam2
229+ ParameterValue: myValue2
230+ `
231+ const json = parseParameters ( yaml )
232+ expect ( json ) . toEqual ( [
233+ {
234+ ParameterKey : 'MyParam1' ,
235+ ParameterValue : 'myValue1'
236+ } ,
237+ {
238+ ParameterKey : 'MyParam2' ,
239+ ParameterValue : 'myValue2'
240+ }
241+ ] )
242+ } )
243+
244+ test ( 'handles YAML with nested values' , async ( ) => {
245+ const yaml = `
246+ MyParam1: myValue1
247+ MyParam2:
248+ - item1
249+ - item2
250+ MyParam3:
251+ key: value
252+ MyParam4: {"key":"value"}
253+ `
254+ const json = parseParameters ( yaml )
255+ expect ( json ) . toEqual ( [
256+ {
257+ ParameterKey : 'MyParam1' ,
258+ ParameterValue : 'myValue1'
259+ } ,
260+ {
261+ ParameterKey : 'MyParam2' ,
262+ ParameterValue : 'item1,item2'
263+ } ,
264+ {
265+ ParameterKey : 'MyParam3' ,
266+ ParameterValue : '{"key":"value"}'
267+ } ,
268+ {
269+ ParameterKey : 'MyParam4' ,
270+ ParameterValue : '{"key":"value"}'
271+ }
272+ ] )
273+ } )
274+
275+ test ( 'handles YAML with boolean and number values' , async ( ) => {
276+ const yaml = `
277+ BoolParam: true
278+ NumberParam: 123
279+ StringParam: 'hello'
280+ NullParam: null
281+ `
282+ const json = parseParameters ( yaml )
283+ expect ( json ) . toEqual ( [
284+ {
285+ ParameterKey : 'BoolParam' ,
286+ ParameterValue : 'true'
287+ } ,
288+ {
289+ ParameterKey : 'NumberParam' ,
290+ ParameterValue : '123'
291+ } ,
292+ {
293+ ParameterKey : 'StringParam' ,
294+ ParameterValue : 'hello'
295+ } ,
296+ {
297+ ParameterKey : 'NullParam' ,
298+ ParameterValue : ''
299+ }
300+ ] )
301+ } )
302+
180303 test ( 'throws error if file is not found' , async ( ) => {
181304 const filename = 'file://' + path . join ( __dirname , 'params.tezt.json' )
182305 expect ( ( ) => parseParameters ( filename ) ) . toThrow ( )
@@ -189,6 +312,155 @@ describe('Parse Parameters', () => {
189312 } )
190313} )
191314
315+ describe ( 'Parse Tags' , ( ) => {
316+ test ( 'parses tags from YAML array format' , ( ) => {
317+ const yaml = `
318+ - Key: Environment
319+ Value: Production
320+ - Key: Project
321+ Value: MyApp
322+ - Key: CostCenter
323+ Value: '12345'
324+ `
325+ const result = parseTags ( yaml )
326+ expect ( result ) . toEqual ( [
327+ {
328+ Key : 'Environment' ,
329+ Value : 'Production'
330+ } ,
331+ {
332+ Key : 'Project' ,
333+ Value : 'MyApp'
334+ } ,
335+ {
336+ Key : 'CostCenter' ,
337+ Value : '12345'
338+ }
339+ ] )
340+ } )
341+
342+ test ( 'parses tags from YAML object format' , ( ) => {
343+ const yaml = `
344+ Environment: Production
345+ Project: MyApp
346+ CostCenter: '12345'
347+ `
348+ const result = parseTags ( yaml )
349+ expect ( result ) . toEqual ( [
350+ {
351+ Key : 'Environment' ,
352+ Value : 'Production'
353+ } ,
354+ {
355+ Key : 'Project' ,
356+ Value : 'MyApp'
357+ } ,
358+ {
359+ Key : 'CostCenter' ,
360+ Value : '12345'
361+ }
362+ ] )
363+ } )
364+
365+ test ( 'handles empty YAML input' , ( ) => {
366+ expect ( parseTags ( '' ) ) . toEqual ( undefined )
367+ expect ( parseTags ( '0' ) ) . toEqual ( undefined )
368+ } )
369+
370+ test ( 'handles YAML with different value types' , ( ) => {
371+ const yaml = `
372+ Environment: Production
373+ IsProduction: true
374+ InstanceCount: 5
375+ FloatValue: 3.14
376+ `
377+ const result = parseTags ( yaml )
378+ expect ( result ) . toEqual ( [
379+ {
380+ Key : 'Environment' ,
381+ Value : 'Production'
382+ } ,
383+ {
384+ Key : 'IsProduction' ,
385+ Value : 'true'
386+ } ,
387+ {
388+ Key : 'InstanceCount' ,
389+ Value : '5'
390+ } ,
391+ {
392+ Key : 'FloatValue' ,
393+ Value : '3.14'
394+ }
395+ ] )
396+ } )
397+
398+ test ( 'handles malformed YAML' , ( ) => {
399+ const malformedYaml = `
400+ This is not valid YAML
401+ - Key: Missing Value
402+ `
403+ expect ( parseTags ( malformedYaml ) ) . toEqual ( undefined )
404+ } )
405+
406+ test ( 'handles array format with missing required fields' , ( ) => {
407+ const yaml = `
408+ - Key: ValidTag
409+ Value: ValidValue
410+ - Value: MissingKey
411+ - Key: MissingValue
412+ `
413+ const result = parseTags ( yaml )
414+ expect ( result ) . toEqual ( [
415+ {
416+ Key : 'ValidTag' ,
417+ Value : 'ValidValue'
418+ }
419+ ] )
420+ } )
421+
422+ test ( 'handles object format with empty values' , ( ) => {
423+ const yaml = `
424+ Environment:
425+ Project: MyApp
426+ EmptyString: ''
427+ `
428+ const result = parseTags ( yaml )
429+ expect ( result ) . toEqual ( [
430+ {
431+ Key : 'Environment' ,
432+ Value : ''
433+ } ,
434+ {
435+ Key : 'Project' ,
436+ Value : 'MyApp'
437+ } ,
438+ {
439+ Key : 'EmptyString' ,
440+ Value : ''
441+ }
442+ ] )
443+ } )
444+
445+ test ( 'preserves whitespace in tag values' , ( ) => {
446+ const yaml = `
447+ Description: This is a long description with spaces
448+ Path: /path/to/something
449+ `
450+ const result = parseTags ( yaml )
451+ expect ( result ) . toEqual ( [
452+ {
453+ Key : 'Description' ,
454+ Value : 'This is a long description with spaces'
455+ } ,
456+ {
457+ Key : 'Path' ,
458+ Value : '/path/to/something'
459+ }
460+ ] )
461+ } )
462+ } )
463+
192464describe ( 'Configure Proxy' , ( ) => {
193465 beforeEach ( ( ) => {
194466 jest . clearAllMocks ( )
0 commit comments