mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Add tests for decline button
This commit is contained in:
parent
9438cefb04
commit
191d86beee
@ -1,6 +1,7 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import CreationConfirm from './CreationConfirm.vue'
|
||||
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
||||
import { rejectContribution } from '../graphql/rejectContribution'
|
||||
import { listUnconfirmedContributions } from '../graphql/listUnconfirmedContributions'
|
||||
import { confirmContribution } from '../graphql/confirmContribution'
|
||||
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
|
||||
@ -75,6 +76,7 @@ describe('CreationConfirm', () => {
|
||||
|
||||
const listUnconfirmedContributionsMock = jest.fn()
|
||||
const adminDeleteContributionMock = jest.fn()
|
||||
const adminDenyContributionMock = jest.fn()
|
||||
const confirmContributionMock = jest.fn()
|
||||
|
||||
mockClient.setRequestHandler(
|
||||
@ -89,6 +91,11 @@ describe('CreationConfirm', () => {
|
||||
adminDeleteContributionMock.mockResolvedValue({ data: { adminDeleteContribution: true } }),
|
||||
)
|
||||
|
||||
mockClient.setRequestHandler(
|
||||
rejectContribution,
|
||||
adminDenyContributionMock.mockResolvedValue({ data: { rejectContribution: true } }),
|
||||
)
|
||||
|
||||
mockClient.setRequestHandler(
|
||||
confirmContribution,
|
||||
confirmContributionMock.mockResolvedValue({ data: { confirmContribution: true } }),
|
||||
@ -243,5 +250,45 @@ describe('CreationConfirm', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('decline creation with success', () => {
|
||||
let spy
|
||||
|
||||
describe('admin confirms decline', () => {
|
||||
beforeEach(async () => {
|
||||
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
|
||||
spy.mockImplementation(() => Promise.resolve('some value'))
|
||||
await wrapper.findAll('tr').at(1).findAll('button').at(3).trigger('click')
|
||||
})
|
||||
|
||||
it('opens a modal', () => {
|
||||
expect(spy).toBeCalled()
|
||||
})
|
||||
|
||||
it('calls the adminDeleteContribution mutation', () => {
|
||||
expect(adminDenyContributionMock).toBeCalledWith({ id: 1 })
|
||||
})
|
||||
|
||||
it('commits openCreationsMinus to store', () => {
|
||||
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1)
|
||||
})
|
||||
|
||||
it('toasts a success message', () => {
|
||||
expect(toastSuccessSpy).toBeCalledWith('creation_form.toasted_rejected')
|
||||
})
|
||||
})
|
||||
|
||||
describe('admin cancels decline', () => {
|
||||
beforeEach(async () => {
|
||||
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
|
||||
spy.mockImplementation(() => Promise.resolve(false))
|
||||
await wrapper.findAll('tr').at(1).findAll('button').at(3).trigger('click')
|
||||
})
|
||||
|
||||
it('does not call the adminDeleteContribution mutation', () => {
|
||||
expect(adminDenyContributionMock).not.toBeCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user