@@ -100,5 +100,58 @@ describe('Entity', () => {
100100 expect ( parameter . name ) . toBe ( 'TestParam' ) ;
101101 expect ( parameter . NoEcho ) . toBe ( true ) ;
102102 } ) ;
103+
104+ it ( 'should handle intrinsic functions in string fields by setting them to undefined' , ( ) => {
105+ const data = {
106+ Type : { 'Fn::Sub' : 'String' } ,
107+ Description : { 'Fn::Sub' : 'Repository for ${AWS::StackName}' } ,
108+ ConstraintDescription : { 'Fn::If' : [ 'Condition' , 'Valid' , 'Invalid' ] } ,
109+ AllowedPattern : { 'Fn::Sub' : '^${AWS::StackName}.*' } ,
110+ Default : 'valid-default' ,
111+ } as any ;
112+
113+ const parameter = Parameter . from ( 'TestParam' , data ) ;
114+
115+ expect ( parameter . name ) . toBe ( 'TestParam' ) ;
116+ expect ( parameter . Type ) . toBeUndefined ( ) ;
117+ expect ( parameter . Default ) . toBe ( 'valid-default' ) ;
118+ expect ( parameter . Description ) . toBeUndefined ( ) ;
119+ expect ( parameter . ConstraintDescription ) . toBeUndefined ( ) ;
120+ expect ( parameter . AllowedPattern ) . toBeUndefined ( ) ;
121+ } ) ;
122+
123+ it ( 'should handle invalid string values in Type field' , ( ) => {
124+ const data = {
125+ Type : 'InvalidParameterType' ,
126+ Description : 'Valid description' ,
127+ Default : 'valid-default' ,
128+ } as any ;
129+
130+ const parameter = Parameter . from ( 'TestParam' , data ) ;
131+
132+ expect ( parameter . name ) . toBe ( 'TestParam' ) ;
133+ expect ( parameter . Type ) . toBeUndefined ( ) ;
134+ expect ( parameter . Description ) . toBe ( 'Valid description' ) ;
135+ expect ( parameter . Default ) . toBe ( 'valid-default' ) ;
136+ } ) ;
137+
138+ it ( 'should coerce numbers and booleans to strings' , ( ) => {
139+ const data = {
140+ Type : ParameterType . String ,
141+ Description : 123 ,
142+ ConstraintDescription : true ,
143+ AllowedPattern : false ,
144+ Default : 'valid-default' ,
145+ } as any ;
146+
147+ const parameter = Parameter . from ( 'TestParam' , data ) ;
148+
149+ expect ( parameter . name ) . toBe ( 'TestParam' ) ;
150+ expect ( parameter . Type ) . toBe ( ParameterType . String ) ;
151+ expect ( parameter . Description ) . toBe ( '123' ) ;
152+ expect ( parameter . ConstraintDescription ) . toBe ( 'true' ) ;
153+ expect ( parameter . AllowedPattern ) . toBe ( 'false' ) ;
154+ expect ( parameter . Default ) . toBe ( 'valid-default' ) ;
155+ } ) ;
103156 } ) ;
104157} ) ;
0 commit comments