1 import { getContactDisplayNameEmail } from '@proton/shared/lib/contacts/contactEmail';
3 describe('getContactDisplayNameEmail', () => {
4 it('displays the email when no name is passed', () => {
5 expect(getContactDisplayNameEmail({ email: 'Hello@proton.ch' })).toEqual({
6 nameEmail: 'Hello@proton.ch',
7 displayOnlyEmail: true,
11 it('displays name and email for a "typical" contact', () => {
12 expect(getContactDisplayNameEmail({ name: 'My dummy friend', email: 'dummy@proton.ch' })).toEqual({
13 nameEmail: 'My dummy friend <dummy@proton.ch>',
14 displayOnlyEmail: false,
18 it('should use different delimiters', () => {
20 getContactDisplayNameEmail({
21 name: 'My dummy friend',
22 email: 'dummy@proton.ch',
23 emailDelimiters: ['(', ')'],
26 nameEmail: 'My dummy friend (dummy@proton.ch)',
27 displayOnlyEmail: false,
31 it('should not repeat name and email', () => {
32 expect(getContactDisplayNameEmail({ name: 'samesame@proton.ch', email: 'samesame@proton.ch' })).toEqual({
33 nameEmail: 'samesame@proton.ch',
34 displayOnlyEmail: true,
38 it('should normalize when comparing name and email', () => {
39 expect(getContactDisplayNameEmail({ name: 'Almost_Same@proton.ch ', email: 'ALMOST_SAME@proton.ch' })).toEqual(
41 nameEmail: 'ALMOST_SAME@proton.ch',
42 displayOnlyEmail: true,