mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Change the removeConfirmResult so we switch over the event possibilities instead of an if else logic.
This commit is contained in:
parent
fedd1d626d
commit
238352bf24
@ -194,14 +194,13 @@ describe('CreationConfirm', () => {
|
||||
|
||||
describe('delete creation delete with error', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' })
|
||||
await wrapper
|
||||
.findComponent({ name: 'UserTable' })
|
||||
.vm.$emit('remove-confirm-result', { id: 1 }, 'confirm')
|
||||
})
|
||||
|
||||
it('toasts an error message', () => {
|
||||
expect(toastedErrorMock).not.toBeCalledWith('Ouchhh!')
|
||||
expect(toastedErrorMock).toBeCalledWith('Case confirm is not supported')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -53,27 +53,32 @@ export default {
|
||||
removeConfirmResult(e, event) {
|
||||
let index = 0
|
||||
const findArr = this.confirmResult.find((arr) => arr.id === e.id)
|
||||
if (event === 'remove') {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: deletePendingCreation,
|
||||
variables: {
|
||||
id: findArr.id,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
index = this.confirmResult.indexOf(findArr)
|
||||
this.confirmResult.splice(index, 1)
|
||||
this.$store.commit('openCreationsMinus', 1)
|
||||
this.$toasted.success('Pending Creation has been deleted')
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
})
|
||||
} else {
|
||||
this.confirmResult.splice(index, 1)
|
||||
this.$store.commit('openCreationsMinus', 1)
|
||||
this.$toasted.success('Pending Creation has been deleted')
|
||||
switch (event) {
|
||||
case 'remove':
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: deletePendingCreation,
|
||||
variables: {
|
||||
id: findArr.id,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
index = this.confirmResult.indexOf(findArr)
|
||||
this.confirmResult.splice(index, 1)
|
||||
this.$store.commit('openCreationsMinus', 1)
|
||||
this.$toasted.success('Pending Creation has been deleted')
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
})
|
||||
break
|
||||
case 'confirmed':
|
||||
this.confirmResult.splice(index, 1)
|
||||
this.$store.commit('openCreationsMinus', 1)
|
||||
this.$toasted.success('Pending Creation has been deleted')
|
||||
break
|
||||
default:
|
||||
this.$toasted.error('Case ' + event + ' is not supported')
|
||||
}
|
||||
},
|
||||
getPendingCreations() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user