@@ -161,6 +161,50 @@ describe("helpers functions", () => {
161161 } ) ;
162162 } ) ;
163163
164+ describe ( "Empty string variables" , ( ) => {
165+ it ( "should replace variables with empty string values correctly" , ( ) => {
166+ const variables = {
167+ smtp_username : "" ,
168+ smtp_password : "" ,
169+ non_empty : "value" ,
170+ } ;
171+
172+ const result1 = processValue ( "${smtp_username}" , variables , mockSchema ) ;
173+ expect ( result1 ) . toBe ( "" ) ;
174+
175+ const result2 = processValue ( "${smtp_password}" , variables , mockSchema ) ;
176+ expect ( result2 ) . toBe ( "" ) ;
177+
178+ const result3 = processValue ( "${non_empty}" , variables , mockSchema ) ;
179+ expect ( result3 ) . toBe ( "value" ) ;
180+ } ) ;
181+
182+ it ( "should not replace undefined variables" , ( ) => {
183+ const variables = {
184+ defined_var : "" ,
185+ } ;
186+
187+ const result = processValue ( "${undefined_var}" , variables , mockSchema ) ;
188+ expect ( result ) . toBe ( "${undefined_var}" ) ;
189+ } ) ;
190+
191+ it ( "should handle mixed empty and non-empty variables in template" , ( ) => {
192+ const variables = {
193+ smtp_address : "smtp.example.com" ,
194+ smtp_port : "2525" ,
195+ smtp_username : "" ,
196+ smtp_password : "" ,
197+ } ;
198+
199+ const template =
200+ "SMTP_ADDRESS=${smtp_address} SMTP_PORT=${smtp_port} SMTP_USERNAME=${smtp_username} SMTP_PASSWORD=${smtp_password}" ;
201+ const result = processValue ( template , variables , mockSchema ) ;
202+ expect ( result ) . toBe (
203+ "SMTP_ADDRESS=smtp.example.com SMTP_PORT=2525 SMTP_USERNAME= SMTP_PASSWORD=" ,
204+ ) ;
205+ } ) ;
206+ } ) ;
207+
164208 describe ( "${jwt}" , ( ) => {
165209 it ( "should generate a JWT string" , ( ) => {
166210 const jwt = processValue ( "${jwt}" , { } , mockSchema ) ;
0 commit comments