Skip to content

The open alternative to Salesforce, designed for AI.

1.1 KB
Raw Blame
import { getPersonEmails } from 'src/modules/match-participant/utils/get-person-emails.util';

describe('getPersonEmails', () => {
  it('should return the primary email followed by the additional emails', () => {
    expect(
      getPersonEmails({
        primaryEmail: '[email protected]',
        additionalEmails: ['[email protected]'],
      }),
    ).toEqual(['[email protected]', '[email protected]']);
  });

  it('should return no emails for a person whose emails field is cleared', () => {
    expect(getPersonEmails({ primaryEmail: '', additionalEmails: [] })).toEqual(
      [],
    );
  });

  it('should return the additional emails when there is no primary email', () => {
    expect(
      getPersonEmails({
        primaryEmail: '',
        additionalEmails: ['[email protected]'],
      }),
    ).toEqual(['[email protected]']);
  });

  it('should return the primary email when additional emails are null', () => {
    expect(
      getPersonEmails({
        primaryEmail: '[email protected]',
        additionalEmails: null,
      }),
    ).toEqual(['[email protected]']);
  });
});