From b89509149605f8cfc71874d3c35423ba06030c14 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 2 Feb 2023 02:47:46 +0100 Subject: [PATCH] fix error messages expected in tests --- .../src/graphql/resolver/UserResolver.test.ts | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index b26d92d76..17eddca94 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -1431,16 +1431,13 @@ describe('UserResolver', () => { mutate({ mutation: setUserRole, variables: { userId: admin.id + 1, isAdmin: true } }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError(`Could not find user with userId: ${admin.id + 1}`)], + errors: [new GraphQLError('Could not find user with given ID')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith( - `Could not find user with userId: ${admin.id + 1}`, - admin.id + 1, - ) + expect(logger.error).toBeCalledWith('Could not find user with given ID', admin.id + 1) }) }) @@ -1606,16 +1603,13 @@ describe('UserResolver', () => { mutate({ mutation: deleteUser, variables: { userId: admin.id + 1 } }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError(`Could not find user with userId: ${admin.id + 1}`)], + errors: [new GraphQLError('Could not find user with given ID')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith( - `Could not find user with userId: ${admin.id + 1}`, - admin.id + 1, - ) + expect(logger.error).toBeCalledWith('Could not find user with given ID', admin.id + 1) }) }) @@ -1660,16 +1654,13 @@ describe('UserResolver', () => { mutate({ mutation: deleteUser, variables: { userId: user.id } }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError(`Could not find user with userId: ${user.id}`)], + errors: [new GraphQLError('Could not find user with given ID')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith( - `Could not find user with userId: ${user.id}`, - user.id, - ) + expect(logger.error).toBeCalledWith('Could not find user with given ID', user.id) }) }) }) @@ -1735,16 +1726,13 @@ describe('UserResolver', () => { mutate({ mutation: unDeleteUser, variables: { userId: admin.id + 1 } }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError(`Could not find user with userId: ${admin.id + 1}`)], + errors: [new GraphQLError('Could not find user with given ID')], }), ) }) it('logs the error thrown', () => { - expect(logger.error).toBeCalledWith( - `Could not find user with userId: ${admin.id + 1}`, - admin.id + 1, - ) + expect(logger.error).toBeCalledWith('Could not find user with given ID', admin.id + 1) }) })