mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Add destructure for denyContribution tests.
This commit is contained in:
parent
4cbfd83d5e
commit
712b64fd06
@ -564,18 +564,13 @@ describe('ContributionResolver', () => {
|
|||||||
describe('denyContribution', () => {
|
describe('denyContribution', () => {
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('returns an error', async () => {
|
it('returns an error', async () => {
|
||||||
await expect(
|
const { errors: errorObjects }: { errors: GraphQLError[] } = await mutate({
|
||||||
mutate({
|
|
||||||
mutation: denyContribution,
|
mutation: denyContribution,
|
||||||
variables: {
|
variables: {
|
||||||
id: 1,
|
id: 1,
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
).resolves.toEqual(
|
expect(errorObjects).toMatchObject([new GraphQLError('401 Unauthorized')])
|
||||||
expect.objectContaining({
|
|
||||||
errors: [new GraphQLError('401 Unauthorized')],
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -592,18 +587,13 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('returns an error', async () => {
|
it('returns an error', async () => {
|
||||||
await expect(
|
const { errors: errorObjects }: { errors: GraphQLError[] } = await mutate({
|
||||||
mutate({
|
|
||||||
mutation: denyContribution,
|
mutation: denyContribution,
|
||||||
variables: {
|
variables: {
|
||||||
id: 1,
|
id: 1,
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
).resolves.toEqual(
|
expect(errorObjects).toMatchObject([new GraphQLError('401 Unauthorized')])
|
||||||
expect.objectContaining({
|
|
||||||
errors: [new GraphQLError('401 Unauthorized')],
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -621,18 +611,15 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
describe('wrong contribution id', () => {
|
describe('wrong contribution id', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
await expect(
|
const { errors: errorObjects }: { errors: GraphQLError[] } = await mutate({
|
||||||
mutate({
|
|
||||||
mutation: denyContribution,
|
mutation: denyContribution,
|
||||||
variables: {
|
variables: {
|
||||||
id: -1,
|
id: -1,
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
).resolves.toEqual(
|
expect(errorObjects).toMatchObject([
|
||||||
expect.objectContaining({
|
new GraphQLError('Contribution not found for given id.'),
|
||||||
errors: [new GraphQLError('Contribution not found for given id.')],
|
])
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
@ -669,18 +656,15 @@ describe('ContributionResolver', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
await expect(
|
const { errors: errorObjects }: { errors: GraphQLError[] } = await mutate({
|
||||||
mutate({
|
|
||||||
mutation: denyContribution,
|
mutation: denyContribution,
|
||||||
variables: {
|
variables: {
|
||||||
id: contribution.data.createContribution.id,
|
id: contribution.data.createContribution.id,
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
).resolves.toEqual(
|
expect(errorObjects).toMatchObject([
|
||||||
expect.objectContaining({
|
new GraphQLError('Contribution not found for given id.'),
|
||||||
errors: [new GraphQLError('Contribution not found for given id.')],
|
])
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
@ -720,18 +704,15 @@ describe('ContributionResolver', () => {
|
|||||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||||
})
|
})
|
||||||
|
|
||||||
await expect(
|
const { errors: errorObjects }: { errors: GraphQLError[] } = await mutate({
|
||||||
mutate({
|
|
||||||
mutation: denyContribution,
|
mutation: denyContribution,
|
||||||
variables: {
|
variables: {
|
||||||
id: contribution.data.createContribution.id,
|
id: contribution.data.createContribution.id,
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
).resolves.toEqual(
|
expect(errorObjects).toMatchObject([
|
||||||
expect.objectContaining({
|
new GraphQLError('Contribution not found for given id.'),
|
||||||
errors: [new GraphQLError('Contribution not found for given id.')],
|
])
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
@ -771,18 +752,15 @@ describe('ContributionResolver', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
await expect(
|
const { errors: errorObjects }: { errors: GraphQLError[] } = await mutate({
|
||||||
mutate({
|
|
||||||
mutation: denyContribution,
|
mutation: denyContribution,
|
||||||
variables: {
|
variables: {
|
||||||
id: contribution.data.createContribution.id,
|
id: contribution.data.createContribution.id,
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
).resolves.toEqual(
|
expect(errorObjects).toMatchObject([
|
||||||
expect.objectContaining({
|
new GraphQLError('Contribution not found for given id.'),
|
||||||
errors: [new GraphQLError('Contribution not found for given id.')],
|
])
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
@ -798,20 +776,15 @@ describe('ContributionResolver', () => {
|
|||||||
mutation: login,
|
mutation: login,
|
||||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||||
})
|
})
|
||||||
await expect(
|
const {
|
||||||
mutate({
|
data: { denyContribution: isDenied },
|
||||||
|
}: { data: { denyContribution: boolean } } = await mutate({
|
||||||
mutation: denyContribution,
|
mutation: denyContribution,
|
||||||
variables: {
|
variables: {
|
||||||
id: contributionToDeny.data.createContribution.id,
|
id: contributionToDeny.data.createContribution.id,
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
).resolves.toEqual(
|
expect(isDenied).toBeTruthy()
|
||||||
expect.objectContaining({
|
|
||||||
data: {
|
|
||||||
denyContribution: true,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -930,32 +903,11 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('stores the delete contribution event in the database', async () => {
|
it('stores the delete contribution event in the database', async () => {
|
||||||
await mutate({
|
|
||||||
mutation: login,
|
|
||||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
|
||||||
})
|
|
||||||
|
|
||||||
const contribution = await mutate({
|
|
||||||
mutation: createContribution,
|
|
||||||
variables: {
|
|
||||||
amount: 166.0,
|
|
||||||
memo: 'Whatever contribution',
|
|
||||||
creationDate: new Date().toString(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
await mutate({
|
|
||||||
mutation: deleteContribution,
|
|
||||||
variables: {
|
|
||||||
id: contribution.data.createContribution.id,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
await expect(EventProtocol.find()).resolves.toContainEqual(
|
await expect(EventProtocol.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventProtocolType.CONTRIBUTION_DELETE,
|
type: EventProtocolType.CONTRIBUTION_DELETE,
|
||||||
contributionId: contribution.data.createContribution.id,
|
contributionId: contributionToDelete.data.createContribution.id,
|
||||||
amount: expect.decimalEqual(166),
|
amount: expect.decimalEqual(100),
|
||||||
userId: peter.id,
|
userId: peter.id,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -979,18 +931,15 @@ describe('ContributionResolver', () => {
|
|||||||
mutation: login,
|
mutation: login,
|
||||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||||
})
|
})
|
||||||
await expect(
|
const { errors: errorObjects }: { errors: [GraphQLError] } = await mutate({
|
||||||
mutate({
|
|
||||||
mutation: deleteContribution,
|
mutation: deleteContribution,
|
||||||
variables: {
|
variables: {
|
||||||
id: contributionToConfirm.data.createContribution.id,
|
id: contributionToConfirm.data.createContribution.id,
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
).resolves.toEqual(
|
expect(errorObjects).toMatchObject([
|
||||||
expect.objectContaining({
|
new GraphQLError('A confirmed contribution can not be deleted'),
|
||||||
errors: [new GraphQLError('A confirmed contribution can not be deleted')],
|
])
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs the error found', () => {
|
it('logs the error found', () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user