Skip to content

Commit

Permalink
👔 add combined name contact sanitizer for contacts without name set
Browse files Browse the repository at this point in the history
  • Loading branch information
sjfrhafe committed Jul 4, 2024
1 parent f4a6b31 commit abbfe02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/util/contact.util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,19 @@ describe('ContactUtil', () => {
},
]);
});

it('should return full name if name is not set', () => {
const mockContact = {
firstName: 'firstName',
lastName: 'lastName',
email: 'email',
phoneNumbers: [],
relatesTo: [],
} as unknown as Contact;

expect(sanitizeContact(mockContact, 'de-DE').name).toEqual(
'firstName lastName',
);
});
});
});
1 change: 1 addition & 0 deletions src/util/contact.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function sanitizeContact(contact: Contact, locale: string): Contact {
relatesTo: contact.relatesTo
? uniqWith(contact.relatesTo, isEqual)
: undefined,
name: contact.name ?? getFullName(contact),
};
return result;
}

0 comments on commit abbfe02

Please sign in to comment.