-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from erz-mba-fbi/feature/138-profile-email
Feature/138 profile email
- Loading branch information
Showing
7 changed files
with
108 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { PersonEmailPipe } from './person-email-pipe'; | ||
import { buildPersonWithEmails } from '../../../spec-builders'; | ||
|
||
describe('person email pipe', () => { | ||
let personEmailPipe: PersonEmailPipe; | ||
|
||
beforeEach(() => { | ||
personEmailPipe = new PersonEmailPipe(); | ||
}); | ||
|
||
it('should return null for a person without any email set', () => { | ||
expect(personEmailPipe.transform(buildPersonWithEmails(12345))).toBeNull(); | ||
}); | ||
|
||
it('should return the first email address if all options have values', () => { | ||
expect( | ||
personEmailPipe.transform( | ||
buildPersonWithEmails( | ||
12345, | ||
'first@email.ch', | ||
'second@email.ch', | ||
'third@email.ch' | ||
) | ||
) | ||
).toBe('first@email.ch'); | ||
}); | ||
|
||
it('should return the first email address with a value ', () => { | ||
expect( | ||
personEmailPipe.transform( | ||
buildPersonWithEmails( | ||
12345, | ||
undefined, | ||
'second@email.ch', | ||
'third@email.ch' | ||
) | ||
) | ||
).toBe('second@email.ch'); | ||
}); | ||
|
||
it('should return the email address with a value - email', () => { | ||
expect( | ||
personEmailPipe.transform( | ||
buildPersonWithEmails(12345, undefined, 'second@email.ch', undefined) | ||
) | ||
).toBe('second@email.ch'); | ||
}); | ||
|
||
it('should return the first email address with a value - email2', () => { | ||
expect( | ||
personEmailPipe.transform( | ||
buildPersonWithEmails(12345, undefined, undefined, 'third@email.ch') | ||
) | ||
).toBe('third@email.ch'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { PipeTransform, Pipe } from '@angular/core'; | ||
import { Person } from '../../shared/models/person.model'; | ||
|
||
@Pipe({ | ||
name: 'erzPersonEmail', | ||
}) | ||
export class PersonEmailPipe implements PipeTransform { | ||
transform(input: Person): Option<string> { | ||
return input.DisplayEmail || input.Email || input.Email2 || null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters