Skip to content

Commit abbfe02

Browse files
committed
👔 add combined name contact sanitizer for contacts without name set
1 parent f4a6b31 commit abbfe02

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/util/contact.util.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,19 @@ describe('ContactUtil', () => {
113113
},
114114
]);
115115
});
116+
117+
it('should return full name if name is not set', () => {
118+
const mockContact = {
119+
firstName: 'firstName',
120+
lastName: 'lastName',
121+
email: 'email',
122+
phoneNumbers: [],
123+
relatesTo: [],
124+
} as unknown as Contact;
125+
126+
expect(sanitizeContact(mockContact, 'de-DE').name).toEqual(
127+
'firstName lastName',
128+
);
129+
});
116130
});
117131
});

src/util/contact.util.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function sanitizeContact(contact: Contact, locale: string): Contact {
3535
relatesTo: contact.relatesTo
3636
? uniqWith(contact.relatesTo, isEqual)
3737
: undefined,
38+
name: contact.name ?? getFullName(contact),
3839
};
3940
return result;
4041
}

0 commit comments

Comments
 (0)