mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
adapt unit tests for creation confirmation page to changes
This commit is contained in:
parent
ca92123209
commit
e607d60962
@ -130,24 +130,39 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('remove creation with success', () => {
|
describe('actions in overlay', () => {
|
||||||
let spy
|
describe('delete creation', () => {
|
||||||
|
|
||||||
describe('admin confirms deletion', () => {
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
|
|
||||||
spy.mockImplementation(() => Promise.resolve('some value'))
|
|
||||||
await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
|
await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens a modal', () => {
|
it('opens the overlay', () => {
|
||||||
expect(spy).toBeCalled()
|
expect(wrapper.find('#overlay').isVisible()).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe(' with success', () => {
|
||||||
|
describe('cancel deletion', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await wrapper.find('#overlay').findAll('button').at(0).trigger('click')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('closes the overlay', async () => {
|
||||||
|
expect(wrapper.find('#overlay').exists()).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('still has 2 items in the table', () => {
|
||||||
|
expect(wrapper.findAll('tbody > tr')).toHaveLength(2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('confirm deletion', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls the adminDeleteContribution mutation', () => {
|
it('calls the adminDeleteContribution mutation', () => {
|
||||||
expect(adminDeleteContributionMock).toBeCalledWith({ id: 1 })
|
expect(adminDeleteContributionMock).toBeCalledWith({ id: 1 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits openCreationsMinus to store', () => {
|
it('commits openCreationsMinus to store', () => {
|
||||||
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1)
|
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1)
|
||||||
})
|
})
|
||||||
@ -155,46 +170,35 @@ describe('CreationConfirm', () => {
|
|||||||
it('toasts a success message', () => {
|
it('toasts a success message', () => {
|
||||||
expect(toastSuccessSpy).toBeCalledWith('creation_form.toasted_delete')
|
expect(toastSuccessSpy).toBeCalledWith('creation_form.toasted_delete')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('has 1 item left in the table', () => {
|
||||||
|
expect(wrapper.findAll('tbody > tr')).toHaveLength(1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('admin cancels deletion', () => {
|
describe('with error', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
|
|
||||||
spy.mockImplementation(() => Promise.resolve(false))
|
|
||||||
await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('does not call the adminDeleteContribution mutation', () => {
|
|
||||||
expect(adminDeleteContributionMock).not.toBeCalled()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('remove creation with error', () => {
|
|
||||||
let spy
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
|
|
||||||
spy.mockImplementation(() => Promise.resolve('some value'))
|
|
||||||
adminDeleteContributionMock.mockRejectedValue({ message: 'Ouchhh!' })
|
adminDeleteContributionMock.mockRejectedValue({ message: 'Ouchhh!' })
|
||||||
await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
|
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('toasts an error message', () => {
|
it('toasts an error message', () => {
|
||||||
expect(toastErrorSpy).toBeCalledWith('Ouchhh!')
|
expect(toastErrorSpy).toBeCalledWith('Ouchhh!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('confirm creation with success', () => {
|
describe('confirm creation', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await wrapper.findAll('tr').at(2).findAll('button').at(2).trigger('click')
|
await wrapper.findAll('tr').at(2).findAll('button').at(2).trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('overlay', () => {
|
|
||||||
it('opens the overlay', () => {
|
it('opens the overlay', () => {
|
||||||
expect(wrapper.find('#overlay').isVisible()).toBeTruthy()
|
expect(wrapper.find('#overlay').isVisible()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('with succes', () => {
|
||||||
describe('cancel confirmation', () => {
|
describe('cancel confirmation', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await wrapper.find('#overlay').findAll('button').at(0).trigger('click')
|
await wrapper.find('#overlay').findAll('button').at(0).trigger('click')
|
||||||
@ -209,7 +213,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('confirm creation', () => {
|
describe('confirm confirmation', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
|
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
|
||||||
})
|
})
|
||||||
@ -230,8 +234,9 @@ describe('CreationConfirm', () => {
|
|||||||
expect(wrapper.findAll('tbody > tr')).toHaveLength(1)
|
expect(wrapper.findAll('tbody > tr')).toHaveLength(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('confirm creation with error', () => {
|
describe('with error', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
confirmContributionMock.mockRejectedValue({ message: 'Ouchhh!' })
|
confirmContributionMock.mockRejectedValue({ message: 'Ouchhh!' })
|
||||||
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
|
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user