Skip to content

Commit

Permalink
Merge pull request #5492 from owncloud/collaboratorRoleUnitTests
Browse files Browse the repository at this point in the history
[unit-tests-only] role of collaborator
  • Loading branch information
individual-it authored Jul 12, 2021
2 parents 1d7ac8e + ae1a157 commit 0078b68
Showing 1 changed file with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const selectors = {
collaboratorName: '.files-collaborators-collaborator-name',
shareType: '.files-collaborators-collaborator-share-type',
reshareInformation: '.files-collaborators-collaborator-reshare-information',
reshareToggleId: 'collaborator-%s-resharer-details-toggle'
reshareToggleId: 'collaborator-%s-resharer-details-toggle',
colaboratorRole: '.files-collaborators-collaborator-role'
}

const resharers = [
Expand Down Expand Up @@ -273,6 +274,37 @@ describe('Collaborator component', () => {
})
})
})
describe('role', () => {
it.each([
{ name: 'viewer', expectedText: 'Viewer' },
{ name: 'editor', expectedText: 'Editor' },
{ name: 'advancedRole', expectedText: 'Advanced permissions' },
{ name: 'owner', expectedText: 'Owner' },
{ name: 'resharer', expectedText: 'Resharer' },
{ name: 'invalidRole', expectedText: 'Unknown Role' }
])('shows the role label', cases => {
const wrapper = createWrapper({
role: { name: cases.name }
})
expect(wrapper.find(selectors.colaboratorRole).text()).toEqual(cases.expectedText)
})

it.each([
{ name: 'viewer', expectedName: 'remove_red_eye' },
{ name: 'editor', expectedName: 'edit' },
{ name: 'advancedRole', expectedName: 'checklist' },
{ name: 'owner', expectedName: 'key' },
{ name: 'resharer', expectedName: 'key' },
{ name: 'invalidRole', expectedName: 'key' }
])('sets the name of the icon', cases => {
const wrapper = createWrapper({
role: { name: cases.name }
})
expect(
wrapper.find(selectors.colaboratorRole + ' oc-icon-stub').attributes('name')
).toEqual(cases.expectedName)
})
})
})
})

Expand All @@ -284,7 +316,8 @@ function createWrapper({
additionalInfo: 'brian@owncloud.com'
},
currentUserId = 'carol',
resharers
resharers,
role = { name: 'viewer' }
} = {}) {
return mount(Collaborator, {
store: new Vuex.Store({
Expand Down Expand Up @@ -312,7 +345,7 @@ function createWrapper({
collaborator: collaborator,
shareType: shareType,
resharers: resharers,
role: { name: 'viewer' }
role: role
}
},
localVue,
Expand Down

0 comments on commit 0078b68

Please sign in to comment.