Refactor Mailgun config to use getEnvVar and improve checks

- Replace getEnv with getEnvVar for environment variable access - Update
MailgunConfig types to allow undefined values - Enhance
isMailgunConfigured to check for undefined and empty values - Update
isDevelopmentMode to check production status - Improve test mocks for
environment variable handling
This commit is contained in:
William Valentin
2025-09-07 18:36:55 -07:00
parent 16d025e747
commit 22e996e698
2 changed files with 23 additions and 15 deletions

View File

@@ -308,6 +308,7 @@ describe('Mailgun Configuration', () => {
describe('isDevelopmentMode', () => {
test('should return true when not in production and Mailgun not configured', () => {
mockIsProduction.mockReturnValue(false);
mockGetEnvVar.mockReturnValue(undefined);
expect(isDevelopmentMode()).toBe(true);
});
@@ -347,6 +348,8 @@ describe('Mailgun Configuration', () => {
describe('integration scenarios', () => {
test('should work with real environment configuration flow', () => {
// Clear any previous mock implementations
mockGetEnvVar.mockReset();
// Provide stable implementation for multiple calls
mockGetEnvVar.mockImplementation((key: string, defaultValue?: string) => {
switch (key) {