Merge pull request #2705 from gradido/authenticated_tests_for_TransactionLinkResolver

test(backend): authentication tests for TransactionLinkResolver
This commit is contained in:
Ulf Gebhardt 2023-02-17 14:10:37 +01:00 committed by GitHub
commit 40d08120e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,6 +53,21 @@ afterAll(async () => {
describe('TransactionLinkResolver', () => {
describe('createTransactionLink', () => {
describe('unauthenticated', () => {
it('throws an error', async () => {
jest.clearAllMocks()
resetToken()
await expect(
mutate({ mutation: createTransactionLink, variables: { amount: 0, memo: 'Test' } }),
).resolves.toEqual(
expect.objectContaining({
errors: [new GraphQLError('401 Unauthorized')],
}),
)
})
})
describe('authenticated', () => {
beforeAll(async () => {
await mutate({
mutation: login,
@ -114,6 +129,7 @@ describe('TransactionLinkResolver', () => {
expect(logger.error).toBeCalledWith('User has not enough GDD', expect.any(Number))
})
})
})
describe('redeemTransactionLink', () => {
afterAll(async () => {
@ -121,6 +137,21 @@ describe('TransactionLinkResolver', () => {
resetToken()
})
describe('unauthenticated', () => {
it('throws an error', async () => {
jest.clearAllMocks()
resetToken()
await expect(
mutate({ mutation: redeemTransactionLink, variables: { code: 'CL-123456' } }),
).resolves.toEqual(
expect.objectContaining({
errors: [new GraphQLError('401 Unauthorized')],
}),
)
})
})
describe('authenticated', () => {
describe('contributionLink', () => {
describe('input not valid', () => {
beforeAll(async () => {
@ -478,6 +509,7 @@ describe('TransactionLinkResolver', () => {
})
})
})
})
describe('listTransactionLinksAdmin', () => {
const variables = {