Skip to content

Commit

Permalink
remove image icon tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VargaJoe committed Sep 26, 2023
1 parent 7610b12 commit a62e992
Showing 1 changed file with 2 additions and 67 deletions.
69 changes: 2 additions & 67 deletions packages/sn-controls-react/test/reference-grid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ReferencePicker } from '../src/fieldcontrols/reference-grid/reference-p

const defaultSettings = {
Type: 'ReferenceFieldSetting',
AllowedTypes: ['User', 'Group', 'Image'],
AllowedTypes: ['User', 'Group'],
SelectionRoots: ['/Root/IMS', '/Root'],
Name: 'Members',
FieldClassName: 'SenseNet.ContentRepository.Fields.ReferenceField',
Expand All @@ -43,27 +43,6 @@ const userContent = {
},
}

const imageContent = {
Name: 'Test Image',
Path: '/Root/Content/Images/Picture.jpg',
DisplayName: 'Test Image',
Id: 4830,
Type: 'Image',
Enabled: true,
PageCount: 0,
}

const imageContentWithPreview = {
Name: 'Test Image',
Path: '/Root/Content/Images/Picture.jpg',
DisplayName: 'Test Image',
Id: 4830,
Type: 'Image',
Enabled: true,
PageCount: 1,
Version: 'v1.0.A',
}

const repository: any = {
load: jest.fn((props) => {
return { d: userContent }
Expand Down Expand Up @@ -116,7 +95,7 @@ describe('Reference grid field control', () => {
})

expect((wrapper!.update().find(Picker).prop('itemsODataOptions') as ODataParams<Folder>).filter).toBe(
"isOf('Folder') or isOf('User') or isOf('Group') or isOf('Image')",
"isOf('Folder') or isOf('User') or isOf('Group')",
)
})

Expand Down Expand Up @@ -268,49 +247,5 @@ describe('Reference grid field control', () => {

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

it('should render img tag if type is image but PageCount is 0', async () => {
const repo = {
loadCollection: jest.fn(() => {
return { d: { results: [{ ...imageContent }] } }
}),
schemas: {
isContentFromType: jest.fn((a, b) => b === 'Image'),
},
configuration: repository.configuration,
} as any
let wrapper: any
await act(async () => {
wrapper = mount(
<ReferencePicker repository={repo} fieldSettings={{ ...defaultSettings, Type: 'Image' }} path="" />,
)
})

expect(wrapper.update().find('img').prop('src')).toContain(imageContent.Path)
expect(wrapper.update().find('img').prop('alt')).toBe(imageContent.DisplayName)
})

it('should render img tag with thumbnail if type is image but PageCount is greater than 0', async () => {
const repo = {
loadCollection: jest.fn(() => {
return { d: { results: [{ ...imageContentWithPreview }] } }
}),
schemas: {
isContentFromType: jest.fn((a, b) => b === 'Image'),
},
configuration: repository.configuration,
} as any
let wrapper: any
await act(async () => {
wrapper = mount(
<ReferencePicker repository={repo} fieldSettings={{ ...defaultSettings, Type: 'Image' }} path="" />,
)
})

expect(wrapper.update().find('img').prop('src')).toContain(
`${imageContentWithPreview.Path}/Previews/${imageContentWithPreview.Version}/thumbnail1.png`,
)
expect(wrapper.update().find('img').prop('alt')).toBe(imageContentWithPreview.DisplayName)
})
})
})

0 comments on commit a62e992

Please sign in to comment.