mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Check that stubbed component method is called
This commit is contained in:
parent
853ff9b92b
commit
36130d9d7c
@ -105,6 +105,7 @@ describe('CommentList.vue', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Comment emitted reply()', () => {
|
it('Comment emitted reply()', () => {
|
||||||
wrapper.find(Comment).vm.$emit('reply', {
|
wrapper.find(Comment).vm.$emit('reply', {
|
||||||
id: 'commentAuthorId',
|
id: 'commentAuthorId',
|
||||||
|
|||||||
@ -11,7 +11,7 @@ const localVue = global.localVue
|
|||||||
localVue.directive('scrollTo', jest.fn())
|
localVue.directive('scrollTo', jest.fn())
|
||||||
|
|
||||||
describe('PostSlug', () => {
|
describe('PostSlug', () => {
|
||||||
let store, propsData, mocks, stubs, wrapper, Wrapper, spy
|
let store, propsData, mocks, stubs, wrapper, Wrapper
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store = new Vuex.Store({
|
store = new Vuex.Store({
|
||||||
@ -47,17 +47,9 @@ describe('PostSlug', () => {
|
|||||||
query: jest.fn().mockResolvedValue({ data: { PostEmotionsCountByEmotion: {} } }),
|
query: jest.fn().mockResolvedValue({ data: { PostEmotionsCountByEmotion: {} } }),
|
||||||
},
|
},
|
||||||
$scrollTo: jest.fn(),
|
$scrollTo: jest.fn(),
|
||||||
$refs: {
|
|
||||||
editor: {
|
|
||||||
insertReply: jest.fn(),
|
|
||||||
},
|
|
||||||
commentForm: {
|
|
||||||
reply: jest.fn(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
stubs = {
|
stubs = {
|
||||||
HcEditor: { render: () => {}, methods: { insertReply: () => null } },
|
HcEditor: { render: () => {}, methods: { insertReply: jest.fn(() => null) } },
|
||||||
ContentViewer: true,
|
ContentViewer: true,
|
||||||
}
|
}
|
||||||
jest.useFakeTimers()
|
jest.useFakeTimers()
|
||||||
@ -82,7 +74,6 @@ describe('PostSlug', () => {
|
|||||||
},
|
},
|
||||||
ready: true,
|
ready: true,
|
||||||
})
|
})
|
||||||
spy = jest.spyOn(wrapper.vm, 'reply')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('mount', () => {
|
describe('mount', () => {
|
||||||
@ -126,7 +117,10 @@ describe('PostSlug', () => {
|
|||||||
id: 'commentAuthorId',
|
id: 'commentAuthorId',
|
||||||
slug: 'ogerly',
|
slug: 'ogerly',
|
||||||
})
|
})
|
||||||
expect(spy).toHaveBeenCalledTimes(1)
|
expect(stubs.HcEditor.methods.insertReply).toHaveBeenCalledWith({
|
||||||
|
id: 'commentAuthorId',
|
||||||
|
slug: 'ogerly',
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user