diff --git a/SanitizeProfileEmail/__tests__/handler.spec.ts b/SanitizeProfileEmail/__tests__/handler.spec.ts index a29c3b23..657c3e1c 100644 --- a/SanitizeProfileEmail/__tests__/handler.spec.ts +++ b/SanitizeProfileEmail/__tests__/handler.spec.ts @@ -110,7 +110,7 @@ describe("Given a list a profiles to be sanitized with their duplicated e-mail a // 3. should have an item in the profile collection const profiles: ProfileToSanitize[] = [ { - email: mocks.email, + email: mocks.email.toUpperCase() as EmailString, fiscalCode: mocks.fiscalCodes.TO_SANITIZE }, { diff --git a/SanitizeProfileEmail/handler.ts b/SanitizeProfileEmail/handler.ts index 46c471f6..059658a3 100644 --- a/SanitizeProfileEmail/handler.ts +++ b/SanitizeProfileEmail/handler.ts @@ -42,7 +42,8 @@ const getProfile = (fiscalCode: ProfileToSanitize["fiscalCode"]) => ( const isProfileEligibleForUpdate = (duplicatedEmail: EmailString) => ( profile: RetrievedProfile ): boolean => - profile.isEmailValidated === true && profile.email === duplicatedEmail; + profile.isEmailValidated === true && + profile.email?.toLowerCase() === duplicatedEmail.toLowerCase(); const getProfileForUpdate = ( profile: ProfileToSanitize