test(helpers): add tests for handling empty and undefined string variables in templates

- Introduced new test cases to verify the behavior of the `processValue` function when dealing with empty string variables and undefined variables.
- Ensured that empty strings are correctly replaced and undefined variables remain unchanged in the output.
This commit is contained in:
Mauricio Siu
2025-12-13 15:05:57 -06:00
parent 0b45b795e8
commit d875e08d48
2 changed files with 46 additions and 2 deletions

View File

@@ -170,12 +170,12 @@ export function processValue(
}
// If not a utility function, try to get from variables
return variables[varName] || match;
return varName in variables ? (variables[varName] ?? match) : match;
});
// Then replace any remaining ${var} with their values from variables
processedValue = processedValue.replace(/\${([^}]+)}/g, (match, varName) => {
return variables[varName] || match;
return varName in variables ? (variables[varName] ?? match) : match;
});
return processedValue;