mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Forgot to add some files
This commit is contained in:
parent
1339734281
commit
8bb33f23a9
@ -1,28 +1,29 @@
|
|||||||
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
|
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
|
||||||
import DeleteModal from './DeleteModal.vue'
|
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import Styleguide from '@human-connection/styleguide'
|
import Styleguide from '@human-connection/styleguide'
|
||||||
|
import ConfirmModal from './ConfirmModal.vue'
|
||||||
|
import PostHelpers from '~/components/PostHelpers'
|
||||||
|
|
||||||
const localVue = createLocalVue()
|
const localVue = createLocalVue()
|
||||||
|
|
||||||
localVue.use(Vuex)
|
localVue.use(Vuex)
|
||||||
localVue.use(Styleguide)
|
localVue.use(Styleguide)
|
||||||
|
|
||||||
describe('DeleteModal.vue', () => {
|
describe('ConfirmModal.vue', () => {
|
||||||
let Wrapper
|
let Wrapper
|
||||||
let wrapper
|
let wrapper
|
||||||
let propsData
|
let propsData
|
||||||
let mocks
|
let mocks
|
||||||
|
const postName = 'It is a post'
|
||||||
|
const confirmCallback = jest.fn()
|
||||||
|
const cancelCallback = jest.fn()
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
propsData = {
|
propsData = {
|
||||||
type: 'contribution',
|
type: 'contribution',
|
||||||
id: 'p23',
|
id: 'p23',
|
||||||
name: 'It is a post',
|
name: postName,
|
||||||
callbacks: {
|
modalData: PostHelpers.postMenuModalsData(postName, confirmCallback, cancelCallback).delete,
|
||||||
confirm: jest.fn(),
|
|
||||||
cancel: jest.fn(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
mocks = {
|
mocks = {
|
||||||
$t: jest.fn(),
|
$t: jest.fn(),
|
||||||
@ -32,9 +33,13 @@ describe('DeleteModal.vue', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
describe('shallowMount', () => {
|
describe('shallowMount', () => {
|
||||||
Wrapper = () => {
|
Wrapper = () => {
|
||||||
return shallowMount(DeleteModal, {
|
return shallowMount(ConfirmModal, {
|
||||||
propsData,
|
propsData,
|
||||||
mocks,
|
mocks,
|
||||||
localVue,
|
localVue,
|
||||||
@ -61,7 +66,7 @@ describe('DeleteModal.vue', () => {
|
|||||||
...propsData,
|
...propsData,
|
||||||
type: 'contribution',
|
type: 'contribution',
|
||||||
id: 'p23',
|
id: 'p23',
|
||||||
name: 'It is a post',
|
name: postName,
|
||||||
}
|
}
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
})
|
})
|
||||||
@ -72,32 +77,7 @@ describe('DeleteModal.vue', () => {
|
|||||||
[
|
[
|
||||||
'delete.contribution.message',
|
'delete.contribution.message',
|
||||||
{
|
{
|
||||||
name: 'It is a post',
|
name: postName,
|
||||||
},
|
|
||||||
],
|
|
||||||
]
|
|
||||||
expect(calls).toEqual(expect.arrayContaining(expected))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('given a comment', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
propsData = {
|
|
||||||
...propsData,
|
|
||||||
type: 'comment',
|
|
||||||
id: 'c4',
|
|
||||||
name: 'It is the user of the comment',
|
|
||||||
}
|
|
||||||
wrapper = Wrapper()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('mentions comments user name', () => {
|
|
||||||
const calls = mocks.$t.mock.calls
|
|
||||||
const expected = [
|
|
||||||
[
|
|
||||||
'delete.comment.message',
|
|
||||||
{
|
|
||||||
name: 'It is the user of the comment',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
@ -108,7 +88,7 @@ describe('DeleteModal.vue', () => {
|
|||||||
|
|
||||||
describe('mount', () => {
|
describe('mount', () => {
|
||||||
Wrapper = () => {
|
Wrapper = () => {
|
||||||
return mount(DeleteModal, {
|
return mount(ConfirmModal, {
|
||||||
propsData,
|
propsData,
|
||||||
mocks,
|
mocks,
|
||||||
localVue,
|
localVue,
|
||||||
@ -135,7 +115,7 @@ describe('DeleteModal.vue', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('does call the cancel callback', () => {
|
it('does call the cancel callback', () => {
|
||||||
expect(propsData.callbacks.cancel).toHaveBeenCalledTimes(1)
|
expect(cancelCallback).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('emits "close"', () => {
|
it('emits "close"', () => {
|
||||||
@ -161,7 +141,7 @@ describe('DeleteModal.vue', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('does call the confirm callback', () => {
|
it('does call the confirm callback', () => {
|
||||||
expect(propsData.callbacks.confirm).toHaveBeenCalledTimes(1)
|
expect(confirmCallback).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
it('emits close', () => {
|
it('emits close', () => {
|
||||||
expect(wrapper.emitted().close).toHaveLength(1)
|
expect(wrapper.emitted().close).toHaveLength(1)
|
||||||
@ -15,7 +15,7 @@
|
|||||||
</ds-button>
|
</ds-button>
|
||||||
|
|
||||||
<ds-button
|
<ds-button
|
||||||
danger
|
:danger="modalData.buttons.confirm.danger"
|
||||||
class="confirm"
|
class="confirm"
|
||||||
:icon="modalData.buttons.confirm.icon"
|
:icon="modalData.buttons.confirm.icon"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
@ -31,7 +31,7 @@
|
|||||||
import { SweetalertIcon } from 'vue-sweetalert-icons'
|
import { SweetalertIcon } from 'vue-sweetalert-icons'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DeleteModal',
|
name: 'ConfirmModal',
|
||||||
components: {
|
components: {
|
||||||
SweetalertIcon,
|
SweetalertIcon,
|
||||||
},
|
},
|
||||||
Loading…
x
Reference in New Issue
Block a user