mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
extend admin test to keep coverage
This commit is contained in:
parent
e7683fb05a
commit
b6821a56fc
@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils'
|
||||
import ContributionMessagesFormular from './ContributionMessagesFormular'
|
||||
import { toastErrorSpy, toastSuccessSpy } from '../../../test/testSetup'
|
||||
import { adminCreateContributionMessage } from '@/graphql/adminCreateContributionMessage'
|
||||
import { adminUpdateContribution } from '@/graphql/adminUpdateContribution'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
@ -136,6 +137,32 @@ describe('ContributionMessagesFormular', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('update contribution memo from moderator for user created contributions', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setData({
|
||||
form: {
|
||||
memo: 'changed memo',
|
||||
},
|
||||
chatOrMemo: 1,
|
||||
})
|
||||
await wrapper.find('button[data-test="submit-dialog"]').trigger('click')
|
||||
})
|
||||
|
||||
it('adminUpdateContribution was called with contributionId and updated memo', () => {
|
||||
expect(apolloMutateMock).toBeCalledWith({
|
||||
mutation: adminUpdateContribution,
|
||||
variables: {
|
||||
id: 42,
|
||||
memo: 'changed memo',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('toasts an success message', () => {
|
||||
expect(toastSuccessSpy).toBeCalledWith('message.request')
|
||||
})
|
||||
})
|
||||
|
||||
describe('send contribution message with error', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMutateMock.mockRejectedValue({ message: 'OUCH!' })
|
||||
|
||||
@ -64,15 +64,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import { adminCreateContributionMessage } from '@/graphql/adminCreateContributionMessage'
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const adminUpdateContribution = gql`
|
||||
mutation ($id: Int!, $memo: String!) {
|
||||
adminUpdateContribution(id: $id, memo: $memo) {
|
||||
memo
|
||||
}
|
||||
}
|
||||
`
|
||||
import { adminUpdateContribution } from '@/graphql/adminUpdateContribution'
|
||||
|
||||
export default {
|
||||
name: 'ContributionMessagesFormular',
|
||||
|
||||
@ -134,5 +134,26 @@ describe('ContributionMessagesList', () => {
|
||||
expect(wrapper.findComponent({ name: 'ContributionMessagesFormular' }).exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('call updateStatus', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.vm.updateStatus(4)
|
||||
})
|
||||
|
||||
it('emits update-status', () => {
|
||||
expect(wrapper.vm.$root.$emit('update-status', 4)).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('test reload-contribution', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.vm.reloadContribution(3)
|
||||
})
|
||||
|
||||
it('emits reload-contribution', () => {
|
||||
expect(wrapper.emitted('reload-contribution')).toBeTruthy()
|
||||
expect(wrapper.emitted('reload-contribution')[0]).toEqual([3])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -140,5 +140,16 @@ describe('OpenCreationsTable', () => {
|
||||
expect(wrapper.vm.$root.$emit('update-status', 4)).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('test reload-contribution', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.vm.reloadContribution(3)
|
||||
})
|
||||
|
||||
it('emits reload-contribution', () => {
|
||||
expect(wrapper.emitted('reload-contribution')).toBeTruthy()
|
||||
expect(wrapper.emitted('reload-contribution')[0]).toEqual([3])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const adminUpdateContribution = gql`
|
||||
mutation ($id: Int!, $amount: Decimal!, $memo: String!, $creationDate: String!) {
|
||||
mutation ($id: Int!, $amount: Decimal, $memo: String, $creationDate: String) {
|
||||
adminUpdateContribution(id: $id, amount: $amount, memo: $memo, creationDate: $creationDate) {
|
||||
amount
|
||||
date
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user