mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
test transaction list query to raise coverage
This commit is contained in:
parent
c42ee8d264
commit
ad4418d297
@ -20,12 +20,15 @@ import {
|
||||
login,
|
||||
sendCoins,
|
||||
} from '@/seeds/graphql/mutations'
|
||||
import { transactionsQuery } from '@/seeds/graphql/queries'
|
||||
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
||||
import { garrickOllivander } from '@/seeds/users/garrick-ollivander'
|
||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||
import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
||||
|
||||
let mutate: ApolloServerTestClient['mutate'], con: Connection
|
||||
let query: ApolloServerTestClient['query']
|
||||
|
||||
let testEnv: {
|
||||
mutate: ApolloServerTestClient['mutate']
|
||||
query: ApolloServerTestClient['query']
|
||||
@ -35,6 +38,7 @@ let testEnv: {
|
||||
beforeAll(async () => {
|
||||
testEnv = await testEnvironment(logger)
|
||||
mutate = testEnv.mutate
|
||||
query = testEnv.query
|
||||
con = testEnv.con
|
||||
await cleanDB()
|
||||
})
|
||||
@ -442,3 +446,42 @@ describe('send coins', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('transactionList', () => {
|
||||
describe('unauthenticated', () => {
|
||||
it('throws an error', async () => {
|
||||
await expect(query({ query: transactionsQuery })).resolves.toMatchObject({
|
||||
errors: [new GraphQLError('401 Unauthorized')],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('authenticated', () => {
|
||||
describe('no transactions', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bobBaumeister)
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: {
|
||||
email: 'bob@baumeister.de',
|
||||
password: 'Aa12345_',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('has no transactions and balance 0', async () => {
|
||||
await expect(query({ query: transactionsQuery })).resolves.toMatchObject({
|
||||
data: {
|
||||
transactionList: {
|
||||
balance: expect.objectContaining({
|
||||
balance: expect.decimalEqual(0),
|
||||
}),
|
||||
transactions: [],
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -23,31 +23,26 @@ export const queryOptIn = gql`
|
||||
`
|
||||
|
||||
export const transactionsQuery = gql`
|
||||
query (
|
||||
$currentPage: Int = 1
|
||||
$pageSize: Int = 25
|
||||
$order: Order = DESC
|
||||
$onlyCreations: Boolean = false
|
||||
) {
|
||||
transactionList(
|
||||
currentPage: $currentPage
|
||||
pageSize: $pageSize
|
||||
order: $order
|
||||
onlyCreations: $onlyCreations
|
||||
) {
|
||||
balanceGDT
|
||||
count
|
||||
balance
|
||||
query ($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) {
|
||||
transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) {
|
||||
balance {
|
||||
balance
|
||||
balanceGDT
|
||||
count
|
||||
linkCount
|
||||
}
|
||||
transactions {
|
||||
id
|
||||
typeId
|
||||
amount
|
||||
balance
|
||||
previousBalance
|
||||
balanceDate
|
||||
memo
|
||||
linkedUser {
|
||||
firstName
|
||||
lastName
|
||||
gradidoID
|
||||
}
|
||||
decay {
|
||||
decay
|
||||
@ -55,6 +50,7 @@ export const transactionsQuery = gql`
|
||||
end
|
||||
duration
|
||||
}
|
||||
linkId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user