mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Change the test so that we can test if the contribution list finds only created but not confirmed contribution
This commit is contained in:
parent
f373562d83
commit
3718f0dc56
@ -13,6 +13,7 @@ import { peterLustig } from '@/seeds/users/peter-lustig'
|
|||||||
|
|
||||||
let mutate: any, query: any, con: any
|
let mutate: any, query: any, con: any
|
||||||
let testEnv: any
|
let testEnv: any
|
||||||
|
let result: any
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
testEnv = await testEnvironment()
|
testEnv = await testEnvironment()
|
||||||
@ -114,6 +115,7 @@ describe('ContributionResolver', () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
data: {
|
data: {
|
||||||
createContribution: {
|
createContribution: {
|
||||||
|
id: expect.any(Number),
|
||||||
amount: '100',
|
amount: '100',
|
||||||
memo: 'Test env contribution',
|
memo: 'Test env contribution',
|
||||||
},
|
},
|
||||||
@ -148,25 +150,22 @@ describe('ContributionResolver', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await userFactory(testEnv, peterLustig)
|
|
||||||
await userFactory(testEnv, bibiBloxberg)
|
await userFactory(testEnv, bibiBloxberg)
|
||||||
// bibi needs GDDs
|
|
||||||
const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de')
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
await creationFactory(testEnv, bibisCreation!)
|
|
||||||
// await userFactory(testEnv, bibiBloxberg)
|
|
||||||
await query({
|
await query({
|
||||||
query: login,
|
query: login,
|
||||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||||
})
|
})
|
||||||
|
await mutate({
|
||||||
|
mutation: createContribution,
|
||||||
|
variables: {
|
||||||
|
amount: 100.0,
|
||||||
|
memo: 'Test env contribution',
|
||||||
|
creationDate: new Date().toString(),
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
it('returns only unconfirmed creations', async () => {
|
||||||
await cleanDB()
|
|
||||||
resetToken()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns an empty array for unconfirmed creation filter', async () => {
|
|
||||||
await expect(
|
await expect(
|
||||||
query({
|
query({
|
||||||
query: listContributions,
|
query: listContributions,
|
||||||
@ -177,39 +176,63 @@ describe('ContributionResolver', () => {
|
|||||||
filterConfirmed: true,
|
filterConfirmed: true,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
data: {
|
|
||||||
listContributions: [],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns confirmed creation', async () => {
|
|
||||||
await expect(
|
|
||||||
query({
|
|
||||||
query: listContributions,
|
|
||||||
variables: {
|
|
||||||
currentPage: 1,
|
|
||||||
pageSize: 25,
|
|
||||||
order: 'DESC',
|
|
||||||
filterConfirmed: false,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
data: {
|
data: {
|
||||||
listContributions: expect.arrayContaining([
|
listContributions: expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
memo: 'Herzlich Willkommen bei Gradido!',
|
id: expect.any(Number),
|
||||||
amount: '1000',
|
memo: 'Test env contribution',
|
||||||
|
amount: '100',
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('Adding confirmed creations', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
await userFactory(testEnv, peterLustig)
|
||||||
|
const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de')
|
||||||
|
await creationFactory(testEnv, bibisCreation!)
|
||||||
|
await query({
|
||||||
|
query: login,
|
||||||
|
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns confirmed and unconfirmed creation', async () => {
|
||||||
|
await expect(
|
||||||
|
query({
|
||||||
|
query: listContributions,
|
||||||
|
variables: {
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 25,
|
||||||
|
order: 'DESC',
|
||||||
|
filterConfirmed: false,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).resolves.toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
data: {
|
||||||
|
listContributions: expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: expect.any(Number),
|
||||||
|
memo: 'Herzlich Willkommen bei Gradido!',
|
||||||
|
amount: '1000',
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: expect.any(Number),
|
||||||
|
memo: 'Test env contribution',
|
||||||
|
amount: '100',
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -234,6 +234,7 @@ export const deleteContributionLink = gql`
|
|||||||
export const createContribution = gql`
|
export const createContribution = gql`
|
||||||
mutation ($amount: Decimal!, $memo: String!, $creationDate: String!) {
|
mutation ($amount: Decimal!, $memo: String!, $creationDate: String!) {
|
||||||
createContribution(amount: $amount, memo: $memo, creationDate: $creationDate) {
|
createContribution(amount: $amount, memo: $memo, creationDate: $creationDate) {
|
||||||
|
id
|
||||||
amount
|
amount
|
||||||
memo
|
memo
|
||||||
}
|
}
|
||||||
|
|||||||
@ -185,6 +185,7 @@ export const listContributions = gql`
|
|||||||
order: $order
|
order: $order
|
||||||
filterConfirmed: $filterConfirmed
|
filterConfirmed: $filterConfirmed
|
||||||
) {
|
) {
|
||||||
|
id
|
||||||
amount
|
amount
|
||||||
memo
|
memo
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user