Skip to content

Commit

Permalink
fixing render problem when given and surname are null on personType o…
Browse files Browse the repository at this point in the history
…bjects
  • Loading branch information
gavinbarron committed Oct 5, 2023
1 parent ac41815 commit 5c50d22
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,20 @@ describe('mgt-person - tests', () => {

expect(screen.queryByTestId('flyout-slot')).toBeDefined();
});

it('should render with initials using the supplied details', async () => {
Providers.globalProvider = new MockProvider(true);
person = await fixture(
`<mgt-person person-details='${JSON.stringify({
displayName: 'Frank Herbert',
mail: 'herbert@dune.net',
givenName: null,
surname: null,
personType: {}
})}' view="twoLines"></mgt-person>`
);
expect(person).not.toBeUndefined();
const initials = await screen.findByText('FH');
expect(initials).toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,7 @@ export class MgtPerson extends MgtTemplatedComponent {
*
* @type {IDynamicPerson}
*/
@property({
attribute: null,
type: Object
})
@state()
private get personDetailsInternal(): IDynamicPerson {
return this._personDetailsInternal;
}
Expand Down Expand Up @@ -1216,8 +1213,8 @@ export class MgtPerson extends MgtTemplatedComponent {

let initials = '';
if (isUser(person)) {
initials += person.givenName[0].toUpperCase();
initials += person.surname[0].toUpperCase();
initials += person.givenName?.[0].toUpperCase() ?? '';
initials += person.surname?.[0].toUpperCase() ?? '';
}

if (!initials && person.displayName) {
Expand Down

0 comments on commit 5c50d22

Please sign in to comment.