Skip to content

Commit

Permalink
avatar monogram test
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanad94 committed Sep 27, 2023
1 parent dca73cc commit 18cf248
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/sn-controls-react/test/reference-grid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,35 @@ describe('Reference grid field control', () => {
expect(wrapper.update().find(Avatar).text()).toBe('A.M')
})

it('should render the monogram of Displayname when no Avatar.Url is provided in DefaultItemTemplate', async () => {
const avatarLessUserContent = { ...userContent, Avatar: { Url: '' } }

const repo = {
loadCollection: jest.fn(() => {
return { d: { results: [avatarLessUserContent] } }
}),
schemas: repository.schemas,
load: jest.fn((props) => {
return { d: avatarLessUserContent }
}),
} as any

let wrapper: any

await act(async () => {
wrapper = mount(
<ReferenceGrid
actionName="browse"
settings={defaultSettings}
content={avatarLessUserContent}
repository={repo}
/>,
)
})

expect(wrapper.update().find(Avatar).text()).toBe('A.M')
})

it('should render img tag if type is image and there is no preview generated', async () => {
const repo = {
loadCollection: jest.fn(() => {
Expand Down Expand Up @@ -300,7 +329,9 @@ describe('Reference grid field control', () => {
return { d: previewImageContent }
}),
} as any

let wrapper: any

await act(async () => {
wrapper = mount(
<ReferenceGrid
Expand Down

0 comments on commit 18cf248

Please sign in to comment.