test for authentication on TransactionLinkResolver

This commit is contained in:
Ulf Gebhardt 2023-02-14 20:31:56 +01:00
parent 0d5370948f
commit 9ff045fdbf
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -53,6 +53,21 @@ afterAll(async () => {
describe('TransactionLinkResolver', () => { describe('TransactionLinkResolver', () => {
describe('createTransactionLink', () => { 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 () => { beforeAll(async () => {
await mutate({ await mutate({
mutation: login, mutation: login,
@ -114,6 +129,7 @@ describe('TransactionLinkResolver', () => {
expect(logger.error).toBeCalledWith('User has not enough GDD', expect.any(Number)) expect(logger.error).toBeCalledWith('User has not enough GDD', expect.any(Number))
}) })
}) })
})
describe('redeemTransactionLink', () => { describe('redeemTransactionLink', () => {
afterAll(async () => { afterAll(async () => {
@ -121,6 +137,21 @@ describe('TransactionLinkResolver', () => {
resetToken() 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('contributionLink', () => {
describe('input not valid', () => { describe('input not valid', () => {
beforeAll(async () => { beforeAll(async () => {
@ -478,6 +509,7 @@ describe('TransactionLinkResolver', () => {
}) })
}) })
}) })
})
describe('listTransactionLinksAdmin', () => { describe('listTransactionLinksAdmin', () => {
const variables = { const variables = {