Skip to content

Commit

Permalink
Merge pull request #5629 from owncloud/unittest-link-list-item
Browse files Browse the repository at this point in the history
Added unit tests for link list item component
  • Loading branch information
individual-it authored Aug 9, 2021
2 parents e38405e + 6b9b9b7 commit c778eda
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import ListItem from '@files/src/components/SideBar/Links/PublicLinks/ListItem.vue'
import { createLocalVue, shallowMount } from '@vue/test-utils'

const localVue = createLocalVue()

describe('ListItem', () => {
function getLinkObject(indirect = false) {
return {
link: {
name: 'public link',
url: 'some-url',
indirect: indirect
}
}
}

function getShallowWrapper(props) {
return shallowMount(ListItem, {
localVue,
propsData: props,
stubs: {
'oc-grid': true,
'link-info': true,
'link-actions': true
}
})
}
it('should show link info component', () => {
const wrapper = getShallowWrapper(getLinkObject())
expect(wrapper.find('link-info-stub').props('link')).toMatchObject({
name: 'public link',
url: 'some-url',
indirect: false
})
})

it('should show link actions component if link is not indirect', () => {
const wrapper = getShallowWrapper(getLinkObject())
const linkActions = wrapper.find('link-actions-stub')
expect(linkActions.exists()).toBeTruthy()
expect(linkActions.props('link')).toMatchObject({
name: 'public link',
url: 'some-url',
indirect: false
})
})
it('should not show link actions component if link is indirect', () => {
const wrapper = getShallowWrapper(getLinkObject(true))
const linkActions = wrapper.find('link-actions-stub')
expect(linkActions.exists()).toBeFalsy()
})
})

0 comments on commit c778eda

Please sign in to comment.