mirror of
https://github.com/IT4Change/gradido.git
synced 2026-04-06 01:25:28 +00:00
bv toast in creation confirm page
This commit is contained in:
parent
b8f4980bda
commit
16501a7488
@ -2,12 +2,11 @@ import { mount } from '@vue/test-utils'
|
|||||||
import CreationConfirm from './CreationConfirm.vue'
|
import CreationConfirm from './CreationConfirm.vue'
|
||||||
import { deletePendingCreation } from '../graphql/deletePendingCreation'
|
import { deletePendingCreation } from '../graphql/deletePendingCreation'
|
||||||
import { confirmPendingCreation } from '../graphql/confirmPendingCreation'
|
import { confirmPendingCreation } from '../graphql/confirmPendingCreation'
|
||||||
|
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
const storeCommitMock = jest.fn()
|
const storeCommitMock = jest.fn()
|
||||||
const toastedErrorMock = jest.fn()
|
|
||||||
const toastedSuccessMock = jest.fn()
|
|
||||||
const apolloQueryMock = jest.fn().mockResolvedValue({
|
const apolloQueryMock = jest.fn().mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
getPendingCreations: [
|
getPendingCreations: [
|
||||||
@ -47,10 +46,6 @@ const mocks = {
|
|||||||
query: apolloQueryMock,
|
query: apolloQueryMock,
|
||||||
mutate: apolloMutateMock,
|
mutate: apolloMutateMock,
|
||||||
},
|
},
|
||||||
$toasted: {
|
|
||||||
error: toastedErrorMock,
|
|
||||||
success: toastedSuccessMock,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('CreationConfirm', () => {
|
describe('CreationConfirm', () => {
|
||||||
@ -101,7 +96,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts a success message', () => {
|
it('toasts a success message', () => {
|
||||||
expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_delete')
|
expect(toastSuccessSpy).toBeCalledWith('creation_form.toasted_delete')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -112,7 +107,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts an error message', () => {
|
it('toasts an error message', () => {
|
||||||
expect(toastedErrorMock).toBeCalledWith('Ouchhh!')
|
expect(toastErrorSpy).toBeCalledWith('Ouchhh!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -158,7 +153,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts a success message', () => {
|
it('toasts a success message', () => {
|
||||||
expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_created')
|
expect(toastSuccessSpy).toBeCalledWith('creation_form.toasted_created')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has 1 item left in the table', () => {
|
it('has 1 item left in the table', () => {
|
||||||
@ -173,7 +168,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts an error message', () => {
|
it('toasts an error message', () => {
|
||||||
expect(toastedErrorMock).toBeCalledWith('Ouchhh!')
|
expect(toastErrorSpy).toBeCalledWith('Ouchhh!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -189,7 +184,7 @@ describe('CreationConfirm', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toast an error message', () => {
|
it('toast an error message', () => {
|
||||||
expect(toastedErrorMock).toBeCalledWith('Ouch!')
|
expect(toastErrorSpy).toBeCalledWith('Ouch!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -43,10 +43,10 @@ export default {
|
|||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.updatePendingCreations(item.id)
|
this.updatePendingCreations(item.id)
|
||||||
this.$toasted.success(this.$t('creation_form.toasted_delete'))
|
this.toastSuccess(this.$t('creation_form.toasted_delete'))
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.toastError(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
confirmCreation() {
|
confirmCreation() {
|
||||||
@ -60,11 +60,11 @@ export default {
|
|||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.overlay = false
|
this.overlay = false
|
||||||
this.updatePendingCreations(this.item.id)
|
this.updatePendingCreations(this.item.id)
|
||||||
this.$toasted.success(this.$t('creation_form.toasted_created'))
|
this.toastSuccess(this.$t('creation_form.toasted_created'))
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.overlay = false
|
this.overlay = false
|
||||||
this.$toasted.error(error.message)
|
this.toastError(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getPendingCreations() {
|
getPendingCreations() {
|
||||||
@ -79,7 +79,7 @@ export default {
|
|||||||
this.$store.commit('setOpenCreations', result.data.getPendingCreations.length)
|
this.$store.commit('setOpenCreations', result.data.getPendingCreations.length)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.toastError(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updatePendingCreations(id) {
|
updatePendingCreations(id) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user