diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 6817b1063..e512961e7 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -74,6 +74,7 @@ describe('ContributionResolver', () => { describe('input not valid', () => { it('throws error when memo length smaller than 5 chars', async () => { + jest.clearAllMocks() const date = new Date() await expect( mutate({ @@ -92,10 +93,11 @@ describe('ContributionResolver', () => { }) it('logs the error found', () => { - expect(logger.error).toBeCalledWith(`memo text is too short: memo.length=4 < (5)`) + expect(logger.error).toBeCalledWith(`memo text is too short: memo.length=4 < 5`) }) it('throws error when memo length greater than 255 chars', async () => { + jest.clearAllMocks() const date = new Date() await expect( mutate({ @@ -114,10 +116,11 @@ describe('ContributionResolver', () => { }) it('logs the error found', () => { - expect(logger.error).toBeCalledWith(`memo text is too long: memo.length=259 > (255)`) + expect(logger.error).toBeCalledWith(`memo text is too long: memo.length=259 > 255`) }) it('throws error when creationDate not-valid', async () => { + jest.clearAllMocks() await expect( mutate({ mutation: createContribution, @@ -144,6 +147,7 @@ describe('ContributionResolver', () => { }) it('throws error when creationDate 3 month behind', async () => { + jest.clearAllMocks() const date = new Date() await expect( mutate({ @@ -420,7 +424,7 @@ describe('ContributionResolver', () => { }) it('logs the error found', () => { - expect(logger.error).toBeCalledWith('memo text is too short: memo.length=4 < (5)') + expect(logger.error).toBeCalledWith('memo text is too short: memo.length=4 < 5') }) }) @@ -446,7 +450,7 @@ describe('ContributionResolver', () => { }) it('logs the error found', () => { - expect(logger.error).toBeCalledWith('memo text is too long: memo.length=259 > (255)') + expect(logger.error).toBeCalledWith('memo text is too long: memo.length=259 > 255') }) }) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 0406f7444..ce95a4c93 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -30,12 +30,12 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { if (memo.length > MEMO_MAX_CHARS) { - logger.error(`memo text is too long: memo.length=${memo.length} > (${MEMO_MAX_CHARS})`) + logger.error(`memo text is too long: memo.length=${memo.length} > ${MEMO_MAX_CHARS}`) throw new Error(`memo text is too long (${MEMO_MAX_CHARS} characters maximum)`) } if (memo.length < MEMO_MIN_CHARS) { - logger.error(`memo text is too short: memo.length=${memo.length} < (${MEMO_MIN_CHARS})`) + logger.error(`memo text is too short: memo.length=${memo.length} < ${MEMO_MIN_CHARS}`) throw new Error(`memo text is too short (${MEMO_MIN_CHARS} characters minimum)`) } @@ -170,12 +170,12 @@ export class ContributionResolver { @Ctx() context: Context, ): Promise { if (memo.length > MEMO_MAX_CHARS) { - logger.error(`memo text is too long: memo.length=${memo.length} > (${MEMO_MAX_CHARS})`) + logger.error(`memo text is too long: memo.length=${memo.length} > ${MEMO_MAX_CHARS}`) throw new Error(`memo text is too long (${MEMO_MAX_CHARS} characters maximum)`) } if (memo.length < MEMO_MIN_CHARS) { - logger.error(`memo text is too short: memo.length=${memo.length} < (${MEMO_MIN_CHARS})`) + logger.error(`memo text is too short: memo.length=${memo.length} < ${MEMO_MIN_CHARS}`) throw new Error(`memo text is too short (${MEMO_MIN_CHARS} characters minimum)`) }