-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5629 from owncloud/unittest-link-list-item
Added unit tests for link list item component
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
packages/web-app-files/tests/unit/components/SideBar/Links/PublicLinks/ListItem.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) | ||
}) |