mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Improve test by mounting CommentList with data
This commit is contained in:
parent
da218f8a58
commit
70fb34345d
@ -21,6 +21,7 @@ describe('CommentList.vue', () => {
|
|||||||
let store
|
let store
|
||||||
let wrapper
|
let wrapper
|
||||||
let propsData
|
let propsData
|
||||||
|
let data
|
||||||
|
|
||||||
propsData = {
|
propsData = {
|
||||||
post: { id: 1 }
|
post: { id: 1 }
|
||||||
@ -35,10 +36,15 @@ describe('CommentList.vue', () => {
|
|||||||
mocks = {
|
mocks = {
|
||||||
$t: jest.fn()
|
$t: jest.fn()
|
||||||
}
|
}
|
||||||
|
data = () => {
|
||||||
|
return {
|
||||||
|
comments: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
describe('shallowMount', () => {
|
describe('shallowMount', () => {
|
||||||
const Wrapper = () => {
|
const Wrapper = () => {
|
||||||
return mount(CommentList, { store, mocks, localVue, propsData })
|
return mount(CommentList, { store, mocks, localVue, propsData, data })
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -48,6 +54,10 @@ describe('CommentList.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('displays a message icon when there are no comments to display', () => {
|
||||||
|
expect(Wrapper().findAll(Empty)).toHaveLength(1)
|
||||||
|
})
|
||||||
|
|
||||||
it('displays a comments counter', () => {
|
it('displays a comments counter', () => {
|
||||||
expect(wrapper.find('span.ds-tag').text()).toEqual('1')
|
expect(wrapper.find('span.ds-tag').text()).toEqual('1')
|
||||||
})
|
})
|
||||||
@ -55,10 +65,5 @@ describe('CommentList.vue', () => {
|
|||||||
it('displays comments when there are comments to display', () => {
|
it('displays comments when there are comments to display', () => {
|
||||||
expect(wrapper.find('div#comments').text()).toEqual('this is a comment')
|
expect(wrapper.find('div#comments').text()).toEqual('this is a comment')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('displays a message icon when there are no comments to display', () => {
|
|
||||||
wrapper.setData({ comments: [] })
|
|
||||||
expect(wrapper.findAll(Empty)).toHaveLength(1)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user