@@ -18,7 +18,7 @@ describe("SsmParametersConstruct", () => {
1818 const stack = new Stack ( app , "parameterStack" )
1919
2020 const params = new SsmParametersConstruct ( stack , "TestingParameters" , {
21- stackName : "mock-stack" ,
21+ namePrefix : "mock-stack" ,
2222 parameters : [
2323 {
2424 id : "MockParam1" ,
@@ -127,3 +127,58 @@ describe("SsmParametersConstruct", () => {
127127 expect ( descriptions ) . toContain ( "Mock read policy output description" )
128128 } )
129129} )
130+
131+ describe ( "SsmParametersConstruct validation" , ( ) => {
132+ test ( "throws when parameters array is empty" , ( ) => {
133+ const app = new App ( )
134+ const stack = new Stack ( app , "emptyParamStack" )
135+ expect ( ( ) => new SsmParametersConstruct ( stack , "EmptyParameters" , {
136+ namePrefix : "mock-stack" ,
137+ parameters : [ ]
138+ } ) ) . toThrow ( "SsmParametersConstruct requires at least one parameter definition" )
139+ } )
140+
141+ test ( "throws when duplicate parameter ids are detected" , ( ) => {
142+ const app = new App ( )
143+ const stack = new Stack ( app , "duplicateIdStack" )
144+ expect ( ( ) => new SsmParametersConstruct ( stack , "DuplicateIdParameters" , {
145+ namePrefix : "mock-stack" ,
146+ parameters : [
147+ {
148+ id : "MockParam1" ,
149+ nameSuffix : "MockParam1" ,
150+ description : "Description for mock parameter 1" ,
151+ value : "mock-value-1"
152+ } ,
153+ {
154+ id : "MockParam1" ,
155+ nameSuffix : "MockParam1Different" ,
156+ description : "Description for duplicate id parameter" ,
157+ value : "mock-value-2"
158+ }
159+ ]
160+ } ) ) . toThrow ( "Duplicate parameter id detected: MockParam1." )
161+ } )
162+
163+ test ( "throws when duplicate parameter names are detected" , ( ) => {
164+ const app = new App ( )
165+ const stack = new Stack ( app , "duplicateNameStack" )
166+ expect ( ( ) => new SsmParametersConstruct ( stack , "DuplicateNameParameters" , {
167+ namePrefix : "mock-stack" ,
168+ parameters : [
169+ {
170+ id : "MockParam1" ,
171+ nameSuffix : "SharedSuffix" ,
172+ description : "Description for mock parameter 1" ,
173+ value : "mock-value-1"
174+ } ,
175+ {
176+ id : "MockParam2" ,
177+ nameSuffix : "SharedSuffix" ,
178+ description : "Description for duplicate name parameter" ,
179+ value : "mock-value-2"
180+ }
181+ ]
182+ } ) ) . toThrow ( "Duplicate parameter name detected: mock-stack-SharedSuffix." )
183+ } )
184+ } )
0 commit comments