mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
catch error for not existing users and test this
This commit is contained in:
parent
dec47d6dc5
commit
5f8702c3c4
@ -600,6 +600,26 @@ describe('TransactionLinkResolver', () => {
|
||||
resetToken()
|
||||
})
|
||||
|
||||
describe('', () => {
|
||||
it('throws error when user does not exists', async () => {
|
||||
jest.clearAllMocks()
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: listTransactionLinksAdmin,
|
||||
variables: {
|
||||
userId: -1,
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: [new GraphQLError('Could not find requested User')],
|
||||
})
|
||||
})
|
||||
|
||||
it('logs the error thrown', () => {
|
||||
expect(logger.error).toBeCalledWith('Could not find requested User', -1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('without any filters', () => {
|
||||
it('finds 6 open transaction links and no deleted or redeemed', async () => {
|
||||
await expect(
|
||||
|
||||
@ -346,6 +346,10 @@ export class TransactionLinkResolver {
|
||||
@Arg('userId', () => Int)
|
||||
userId: number,
|
||||
): Promise<TransactionLinkResult> {
|
||||
return transactionLinkList(paginated, filters, await DbUser.findOneOrFail({ id: userId }))
|
||||
const user = await DbUser.findOne({ id: userId })
|
||||
if (!user) {
|
||||
throw new LogError('Could not find requested User', userId)
|
||||
}
|
||||
return transactionLinkList(paginated, filters, user)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user