Merge pull request #2816 from gradido/eslint-plugin-jest-fixes

refactor(backend): eslint-plugin-jest + fixes
This commit is contained in:
Ulf Gebhardt 2023-03-28 00:51:27 +02:00 committed by GitHub
commit 2cf2a75df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 131 additions and 65 deletions

View File

@ -4,7 +4,7 @@ module.exports = {
node: true, node: true,
}, },
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
plugins: ['prettier', '@typescript-eslint', 'type-graphql'], plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'],
extends: ['standard', 'eslint:recommended', 'plugin:prettier/recommended'], extends: ['standard', 'eslint:recommended', 'plugin:prettier/recommended'],
// add your custom rules here // add your custom rules here
rules: { rules: {
@ -16,11 +16,17 @@ module.exports = {
htmlWhitespaceSensitivity: 'ignore', htmlWhitespaceSensitivity: 'ignore',
}, },
], ],
// jest
'jest/no-disabled-tests': 'error',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'error',
'jest/valid-expect': 'error',
}, },
overrides: [ overrides: [
// only for ts files // only for ts files
{ {
files: ['*.ts'], files: ['*.ts', '*.tsx'],
extends: [ extends: [
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking', 'plugin:@typescript-eslint/recommended-requiring-type-checking',

View File

@ -62,6 +62,7 @@
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.3", "eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4", "eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0", "eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-promise": "^5.1.0", "eslint-plugin-promise": "^5.1.0",

View File

@ -102,10 +102,12 @@ describe('sendEmailTranslated', () => {
}) })
}) })
// eslint-disable-next-line jest/no-disabled-tests
it.skip('calls "i18n.setLocale" with "en"', () => { it.skip('calls "i18n.setLocale" with "en"', () => {
expect(i18n.setLocale).toBeCalledWith('en') expect(i18n.setLocale).toBeCalledWith('en')
}) })
// eslint-disable-next-line jest/no-disabled-tests
it.skip('calls "i18n.__" for translation', () => { it.skip('calls "i18n.__" for translation', () => {
expect(i18n.__).toBeCalled() expect(i18n.__).toBeCalled()
}) })

View File

@ -280,7 +280,7 @@ describe('Contribution Links', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "A Start-Date must be set"', () => {
expect(logger.error).toBeCalledWith('A Start-Date must be set') expect(logger.error).toBeCalledWith('A Start-Date must be set')
}) })
@ -301,7 +301,7 @@ describe('Contribution Links', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "An End-Date must be set"', () => {
expect(logger.error).toBeCalledWith('An End-Date must be set') expect(logger.error).toBeCalledWith('An End-Date must be set')
}) })
@ -325,7 +325,7 @@ describe('Contribution Links', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "The value of validFrom must before or equals the validTo"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
`The value of validFrom must before or equals the validTo`, `The value of validFrom must before or equals the validTo`,
) )
@ -348,7 +348,7 @@ describe('Contribution Links', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "The value of name is too short"', () => {
expect(logger.error).toBeCalledWith('The value of name is too short', 3) expect(logger.error).toBeCalledWith('The value of name is too short', 3)
}) })
@ -369,7 +369,7 @@ describe('Contribution Links', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "The value of name is too long"', () => {
expect(logger.error).toBeCalledWith('The value of name is too long', 101) expect(logger.error).toBeCalledWith('The value of name is too long', 101)
}) })
@ -390,7 +390,7 @@ describe('Contribution Links', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "The value of memo is too short"', () => {
expect(logger.error).toBeCalledWith('The value of memo is too short', 3) expect(logger.error).toBeCalledWith('The value of memo is too short', 3)
}) })
@ -411,7 +411,7 @@ describe('Contribution Links', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "The value of memo is too long"', () => {
expect(logger.error).toBeCalledWith('The value of memo is too long', 256) expect(logger.error).toBeCalledWith('The value of memo is too long', 256)
}) })
@ -432,7 +432,7 @@ describe('Contribution Links', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "The amount must be a positiv value"', () => {
expect(logger.error).toBeCalledWith('The amount must be a positiv value', new Decimal(0)) expect(logger.error).toBeCalledWith('The amount must be a positiv value', new Decimal(0))
}) })
}) })
@ -490,7 +490,7 @@ describe('Contribution Links', () => {
}) })
}) })
it('logs the error thrown', () => { it('logs the error "Contribution Link not found"', () => {
expect(logger.error).toBeCalledWith('Contribution Link not found', -1) expect(logger.error).toBeCalledWith('Contribution Link not found', -1)
}) })
@ -572,7 +572,7 @@ describe('Contribution Links', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "Contribution Link not found"', () => {
expect(logger.error).toBeCalledWith('Contribution Link not found', -1) expect(logger.error).toBeCalledWith('Contribution Link not found', -1)
}) })
}) })

View File

@ -115,7 +115,7 @@ describe('ContributionMessageResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "ContributionMessage was not sent successfully: Error: Contribution not found"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'ContributionMessage was not sent successfully: Error: Contribution not found', 'ContributionMessage was not sent successfully: Error: Contribution not found',
new Error('Contribution not found'), new Error('Contribution not found'),
@ -155,7 +155,7 @@ describe('ContributionMessageResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "ContributionMessage was not sent successfully: Error: Admin can not answer on his own contribution"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'ContributionMessage was not sent successfully: Error: Admin can not answer on his own contribution', 'ContributionMessage was not sent successfully: Error: Admin can not answer on his own contribution',
new Error('Admin can not answer on his own contribution'), new Error('Admin can not answer on his own contribution'),
@ -265,7 +265,7 @@ describe('ContributionMessageResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "ContributionMessage was not sent successfully: Error: Contribution not found"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'ContributionMessage was not sent successfully: Error: Contribution not found', 'ContributionMessage was not sent successfully: Error: Contribution not found',
new Error('Contribution not found'), new Error('Contribution not found'),
@ -297,7 +297,7 @@ describe('ContributionMessageResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "ContributionMessage was not sent successfully: Error: Can not send message to contribution of another user"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'ContributionMessage was not sent successfully: Error: Can not send message to contribution of another user', 'ContributionMessage was not sent successfully: Error: Can not send message to contribution of another user',
new Error('Can not send message to contribution of another user'), new Error('Can not send message to contribution of another user'),

View File

@ -201,7 +201,7 @@ describe('ContributionResolver', () => {
expect(errorObjects).toEqual([new GraphQLError('Memo text is too short')]) expect(errorObjects).toEqual([new GraphQLError('Memo text is too short')])
}) })
it('logs the error found', () => { it('logs the error "Memo text is too short"', () => {
expect(logger.error).toBeCalledWith('Memo text is too short', 4) expect(logger.error).toBeCalledWith('Memo text is too short', 4)
}) })
@ -219,7 +219,7 @@ describe('ContributionResolver', () => {
expect(errorObjects).toEqual([new GraphQLError('Memo text is too long')]) expect(errorObjects).toEqual([new GraphQLError('Memo text is too long')])
}) })
it('logs the error found', () => { it('logs the error "Memo text is too long"', () => {
expect(logger.error).toBeCalledWith('Memo text is too long', 259) expect(logger.error).toBeCalledWith('Memo text is too long', 259)
}) })
@ -238,7 +238,7 @@ describe('ContributionResolver', () => {
]) ])
}) })
it('logs the error found', () => { it('logs the error "No information for available creations for the given date"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'No information for available creations for the given date', 'No information for available creations for the given date',
expect.any(Date), expect.any(Date),
@ -261,7 +261,7 @@ describe('ContributionResolver', () => {
]) ])
}) })
it('logs the error found', () => { it('logs the error "No information for available creations for the given date" again', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'No information for available creations for the given date', 'No information for available creations for the given date',
expect.any(Date), expect.any(Date),
@ -337,7 +337,7 @@ describe('ContributionResolver', () => {
expect(errorObjects).toEqual([new GraphQLError('Memo text is too short')]) expect(errorObjects).toEqual([new GraphQLError('Memo text is too short')])
}) })
it('logs the error found', () => { it('logs the error "Memo text is too short"', () => {
expect(logger.error).toBeCalledWith('Memo text is too short', 4) expect(logger.error).toBeCalledWith('Memo text is too short', 4)
}) })
}) })
@ -358,7 +358,7 @@ describe('ContributionResolver', () => {
expect(errorObjects).toEqual([new GraphQLError('Memo text is too long')]) expect(errorObjects).toEqual([new GraphQLError('Memo text is too long')])
}) })
it('logs the error found', () => { it('logs the error "Memo text is too long"', () => {
expect(logger.error).toBeCalledWith('Memo text is too long', 259) expect(logger.error).toBeCalledWith('Memo text is too long', 259)
}) })
}) })
@ -383,7 +383,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error found', () => { it('logs the error "Contribution not found"', () => {
expect(logger.error).toBeCalledWith('Contribution not found', -1) expect(logger.error).toBeCalledWith('Contribution not found', -1)
}) })
}) })
@ -412,7 +412,7 @@ describe('ContributionResolver', () => {
]) ])
}) })
it('logs the error found', () => { it('logs the error "Can not update contribution of another user"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Can not update contribution of another user', 'Can not update contribution of another user',
expect.any(Object), expect.any(Object),
@ -446,7 +446,7 @@ describe('ContributionResolver', () => {
]) ])
}) })
it('logs the error found', () => { it('logs the error "An admin is not allowed to update an user contribution"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'An admin is not allowed to update an user contribution', 'An admin is not allowed to update an user contribution',
) )
@ -492,7 +492,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error found', () => { it('logs the error "Contribution can not be updated due to status"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Contribution can not be updated due to status', 'Contribution can not be updated due to status',
ContributionStatus.DELETED, ContributionStatus.DELETED,
@ -527,7 +527,7 @@ describe('ContributionResolver', () => {
]) ])
}) })
it('logs the error found', () => { it('logs the error "The amount to be created exceeds the amount still available for this month"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'The amount to be created exceeds the amount still available for this month', 'The amount to be created exceeds the amount still available for this month',
new Decimal(1019), new Decimal(1019),
@ -554,7 +554,7 @@ describe('ContributionResolver', () => {
]) ])
}) })
it('logs the error found', () => { it('logs the error "Month of contribution can not be changed"', () => {
expect(logger.error).toBeCalledWith('Month of contribution can not be changed') expect(logger.error).toBeCalledWith('Month of contribution can not be changed')
}) })
}) })
@ -659,7 +659,7 @@ describe('ContributionResolver', () => {
expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) expect(errorObjects).toEqual([new GraphQLError('Contribution not found')])
}) })
it('logs the error found', () => { it('logs the error "Contribution not found"', () => {
expect(logger.error).toBeCalledWith('Contribution not found', -1) expect(logger.error).toBeCalledWith('Contribution not found', -1)
}) })
}) })
@ -703,7 +703,7 @@ describe('ContributionResolver', () => {
expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) expect(errorObjects).toEqual([new GraphQLError('Contribution not found')])
}) })
it('logs the error found', () => { it('logs the error "Contribution not found"', () => {
expect(logger.error).toBeCalledWith('Contribution not found', expect.any(Number)) expect(logger.error).toBeCalledWith('Contribution not found', expect.any(Number))
}) })
}) })
@ -748,7 +748,7 @@ describe('ContributionResolver', () => {
expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) expect(errorObjects).toEqual([new GraphQLError('Contribution not found')])
}) })
it('logs the error found', () => { it('logs the error "Contribution not found"', () => {
expect(logger.error).toBeCalledWith(`Contribution not found`, expect.any(Number)) expect(logger.error).toBeCalledWith(`Contribution not found`, expect.any(Number))
}) })
}) })
@ -793,7 +793,7 @@ describe('ContributionResolver', () => {
expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) expect(errorObjects).toEqual([new GraphQLError('Contribution not found')])
}) })
it('logs the error found', () => { it('logs the error "Contribution not found"', () => {
expect(logger.error).toBeCalledWith(`Contribution not found`, expect.any(Number)) expect(logger.error).toBeCalledWith(`Contribution not found`, expect.any(Number))
}) })
}) })
@ -879,7 +879,7 @@ describe('ContributionResolver', () => {
expect(errorObjects).toEqual([new GraphQLError('Contribution not found')]) expect(errorObjects).toEqual([new GraphQLError('Contribution not found')])
}) })
it('logs the error found', () => { it('logs the error "Contribution not found"', () => {
expect(logger.error).toBeCalledWith('Contribution not found', expect.any(Number)) expect(logger.error).toBeCalledWith('Contribution not found', expect.any(Number))
}) })
}) })
@ -909,7 +909,7 @@ describe('ContributionResolver', () => {
]) ])
}) })
it('logs the error found', () => { it('logs the error "Can not delete contribution of another user"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Can not delete contribution of another user', 'Can not delete contribution of another user',
expect.any(Contribution), expect.any(Contribution),
@ -984,7 +984,7 @@ describe('ContributionResolver', () => {
]) ])
}) })
it('logs the error found', () => { it('logs the error "A confirmed contribution can not be deleted"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'A confirmed contribution can not be deleted', 'A confirmed contribution can not be deleted',
expect.objectContaining({ contributionStatus: 'CONFIRMED' }), expect.objectContaining({ contributionStatus: 'CONFIRMED' }),
@ -1849,7 +1849,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "Could not find user"', () => {
expect(logger.error).toBeCalledWith('Could not find user', 'some@fake.email') expect(logger.error).toBeCalledWith('Could not find user', 'some@fake.email')
}) })
}) })
@ -1876,7 +1876,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "Cannot create contribution since the user was deleted"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Cannot create contribution since the user was deleted', 'Cannot create contribution since the user was deleted',
expect.objectContaining({ expect.objectContaining({
@ -1912,7 +1912,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "Cannot create contribution since the users email is not activated"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Cannot create contribution since the users email is not activated', 'Cannot create contribution since the users email is not activated',
expect.objectContaining({ emailChecked: false }), expect.objectContaining({ emailChecked: false }),
@ -1938,7 +1938,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "CreationDate is invalid"', () => {
expect(logger.error).toBeCalledWith('CreationDate is invalid', 'invalid-date') expect(logger.error).toBeCalledWith('CreationDate is invalid', 'invalid-date')
}) })
}) })
@ -1960,7 +1960,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "No information for available creations for the given date"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'No information for available creations for the given date', 'No information for available creations for the given date',
new Date(variables.creationDate), new Date(variables.creationDate),
@ -1985,7 +1985,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "No information for available creations for the given date"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'No information for available creations for the given date', 'No information for available creations for the given date',
new Date(variables.creationDate), new Date(variables.creationDate),
@ -2010,7 +2010,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "The amount to be created exceeds the amount still available for this month"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'The amount to be created exceeds the amount still available for this month', 'The amount to be created exceeds the amount still available for this month',
new Decimal(2000), new Decimal(2000),
@ -2062,7 +2062,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "The amount to be created exceeds the amount still available for this month"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'The amount to be created exceeds the amount still available for this month', 'The amount to be created exceeds the amount still available for this month',
new Decimal(1000), new Decimal(1000),
@ -2101,7 +2101,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "Could not find User"', () => {
expect(logger.error).toBeCalledWith('Could not find User', 'bob@baumeister.de') expect(logger.error).toBeCalledWith('Could not find User', 'bob@baumeister.de')
}) })
}) })
@ -2127,7 +2127,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "User was deleted"', () => {
expect(logger.error).toBeCalledWith('User was deleted', 'stephen@hawking.uk') expect(logger.error).toBeCalledWith('User was deleted', 'stephen@hawking.uk')
}) })
}) })
@ -2153,7 +2153,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "Contribution not found"', () => {
expect(logger.error).toBeCalledWith('Contribution not found', -1) expect(logger.error).toBeCalledWith('Contribution not found', -1)
}) })
}) })
@ -2185,7 +2185,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "User of the pending contribution and send user does not correspond"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'User of the pending contribution and send user does not correspond', 'User of the pending contribution and send user does not correspond',
) )
@ -2220,7 +2220,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "The amount to be created exceeds the amount still available for this month"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'The amount to be created exceeds the amount still available for this month', 'The amount to be created exceeds the amount still available for this month',
new Decimal(1900), new Decimal(1900),
@ -2229,6 +2229,7 @@ describe('ContributionResolver', () => {
}) })
}) })
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('creation update is successful changing month', () => { describe.skip('creation update is successful changing month', () => {
// skipped as changing the month is currently disable // skipped as changing the month is currently disable
it('returns update creation object', async () => { it('returns update creation object', async () => {
@ -2332,7 +2333,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "Contribution not found"', () => {
expect(logger.error).toBeCalledWith('Contribution not found', -1) expect(logger.error).toBeCalledWith('Contribution not found', -1)
}) })
}) })
@ -2474,7 +2475,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "Contribution not found"', () => {
expect(logger.error).toBeCalledWith('Contribution not found', -1) expect(logger.error).toBeCalledWith('Contribution not found', -1)
}) })
}) })
@ -2508,7 +2509,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('logs the error thrown', () => { it('logs the error "Moderator can not confirm own contribution"', () => {
expect(logger.error).toBeCalledWith('Moderator can not confirm own contribution') expect(logger.error).toBeCalledWith('Moderator can not confirm own contribution')
}) })
}) })
@ -2603,7 +2604,7 @@ describe('ContributionResolver', () => {
}) })
}) })
it('logs the error thrown', () => { it('logs the error "Contribution already confirmed"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Contribution already confirmed', 'Contribution already confirmed',
expect.any(Number), expect.any(Number),

View File

@ -99,7 +99,7 @@ describe('TransactionLinkResolver', () => {
errors: [new GraphQLError('Amount must be a positive number')], errors: [new GraphQLError('Amount must be a positive number')],
}) })
}) })
it('logs the error thrown', () => { it('logs the error "Amount must be a positive number" - 0', () => {
expect(logger.error).toBeCalledWith('Amount must be a positive number', new Decimal(0)) expect(logger.error).toBeCalledWith('Amount must be a positive number', new Decimal(0))
}) })
@ -117,7 +117,7 @@ describe('TransactionLinkResolver', () => {
errors: [new GraphQLError('Amount must be a positive number')], errors: [new GraphQLError('Amount must be a positive number')],
}) })
}) })
it('logs the error thrown', () => { it('logs the error "Amount must be a positive number" - -10', () => {
expect(logger.error).toBeCalledWith('Amount must be a positive number', new Decimal(-10)) expect(logger.error).toBeCalledWith('Amount must be a positive number', new Decimal(-10))
}) })
@ -135,7 +135,7 @@ describe('TransactionLinkResolver', () => {
errors: [new GraphQLError('User has not enough GDD')], errors: [new GraphQLError('User has not enough GDD')],
}) })
}) })
it('logs the error thrown', () => { it('logs the error "User has not enough GDD"', () => {
expect(logger.error).toBeCalledWith('User has not enough GDD', expect.any(Number)) expect(logger.error).toBeCalledWith('User has not enough GDD', expect.any(Number))
}) })
}) })
@ -187,7 +187,7 @@ describe('TransactionLinkResolver', () => {
}) })
}) })
it('logs the error thrown', () => { it('logs the error "No contribution link found to given code"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'No contribution link found to given code', 'No contribution link found to given code',
'CL-123456', 'CL-123456',
@ -231,7 +231,7 @@ describe('TransactionLinkResolver', () => {
await resetEntity(DbContributionLink) await resetEntity(DbContributionLink)
}) })
it('logs the error thrown', () => { it('logs the error "Contribution link is not valid yet"', () => {
expect(logger.error).toBeCalledWith('Contribution link is not valid yet', validFrom) expect(logger.error).toBeCalledWith('Contribution link is not valid yet', validFrom)
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Creation from contribution link was not successful', 'Creation from contribution link was not successful',
@ -270,7 +270,7 @@ describe('TransactionLinkResolver', () => {
await resetEntity(DbContributionLink) await resetEntity(DbContributionLink)
}) })
it('logs the error thrown', () => { it('logs the error "Contribution link has unknown cycle"', () => {
expect(logger.error).toBeCalledWith('Contribution link has unknown cycle', 'INVALID') expect(logger.error).toBeCalledWith('Contribution link has unknown cycle', 'INVALID')
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Creation from contribution link was not successful', 'Creation from contribution link was not successful',
@ -309,7 +309,7 @@ describe('TransactionLinkResolver', () => {
await resetEntity(DbContributionLink) await resetEntity(DbContributionLink)
}) })
it('logs the error thrown', () => { it('logs the error "Contribution link is no longer valid"', () => {
expect(logger.error).toBeCalledWith('Contribution link is no longer valid', validTo) expect(logger.error).toBeCalledWith('Contribution link is no longer valid', validTo)
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Creation from contribution link was not successful', 'Creation from contribution link was not successful',
@ -405,7 +405,7 @@ describe('TransactionLinkResolver', () => {
}) })
}) })
it('logs the error thrown', () => { it('logs the error "Creation from contribution link was not successful"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Creation from contribution link was not successful', 'Creation from contribution link was not successful',
new Error( new Error(
@ -480,7 +480,7 @@ describe('TransactionLinkResolver', () => {
}) })
}) })
it('logs the error thrown', () => { it('logs the error "Creation from contribution link was not successful"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Creation from contribution link was not successful', 'Creation from contribution link was not successful',
new Error('Contribution link already redeemed today'), new Error('Contribution link already redeemed today'),
@ -532,7 +532,7 @@ describe('TransactionLinkResolver', () => {
}) })
}) })
it('logs the error thrown', () => { it('logs the error "Creation from contribution link was not successful"', () => {
expect(logger.error).toBeCalledWith( expect(logger.error).toBeCalledWith(
'Creation from contribution link was not successful', 'Creation from contribution link was not successful',
new Error('Contribution link already redeemed today'), new Error('Contribution link already redeemed today'),
@ -735,7 +735,7 @@ describe('TransactionLinkResolver', () => {
}) })
}) })
it('logs the error thrown', () => { it('logs the error "Could not find requested User"', () => {
expect(logger.error).toBeCalledWith('Could not find requested User', -1) expect(logger.error).toBeCalledWith('Could not find requested User', -1)
}) })
}) })
@ -874,6 +874,7 @@ describe('TransactionLinkResolver', () => {
}) })
// TODO: works not as expected, because 'redeemedAt' and 'redeemedBy' have to be added to the transaktion link factory // TODO: works not as expected, because 'redeemedAt' and 'redeemedBy' have to be added to the transaktion link factory
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('filter by redeemed', () => { describe.skip('filter by redeemed', () => {
it('finds 6 open transaction links, 1 deleted, and no redeemed', async () => { it('finds 6 open transaction links, 1 deleted, and no redeemed', async () => {
await expect( await expect(

View File

@ -797,6 +797,7 @@ describe('UserResolver', () => {
}) })
}) })
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('user is in database but password is not set', () => { describe.skip('user is in database but password is not set', () => {
beforeAll(async () => { beforeAll(async () => {
jest.clearAllMocks() jest.clearAllMocks()

View File

@ -5,8 +5,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import Decimal from 'decimal.js-light' import Decimal from 'decimal.js-light'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { logger } from '@test/testSetup'
import { userFactory } from '@/seeds/factory/user' import { userFactory } from '@/seeds/factory/user'
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { bobBaumeister } from '@/seeds/users/bob-baumeister'

View File

@ -16,6 +16,7 @@ describe('utils/decay', () => {
expect(decayFormula(amount, seconds).toString()).toBe('1.000000021964959992727444') expect(decayFormula(amount, seconds).toString()).toBe('1.000000021964959992727444')
}) })
// we get pretty close, but not exact here, skipping // we get pretty close, but not exact here, skipping
// eslint-disable-next-line jest/no-disabled-tests
it.skip('has correct forward calculation', () => { it.skip('has correct forward calculation', () => {
const amount = new Decimal(1.0).div( const amount = new Decimal(1.0).div(
new Decimal('0.99999997803504048973201202316767079413460520837376'), new Decimal('0.99999997803504048973201202316767079413460520837376'),

View File

@ -1239,6 +1239,14 @@
"@typescript-eslint/types" "5.53.0" "@typescript-eslint/types" "5.53.0"
"@typescript-eslint/visitor-keys" "5.53.0" "@typescript-eslint/visitor-keys" "5.53.0"
"@typescript-eslint/scope-manager@5.54.1":
version "5.54.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.54.1.tgz#6d864b4915741c608a58ce9912edf5a02bb58735"
integrity sha512-zWKuGliXxvuxyM71UA/EcPxaviw39dB2504LqAmFDjmkpO8qNLHcmzlh6pbHs1h/7YQ9bnsO8CCcYCSA8sykUg==
dependencies:
"@typescript-eslint/types" "5.54.1"
"@typescript-eslint/visitor-keys" "5.54.1"
"@typescript-eslint/types@4.33.0": "@typescript-eslint/types@4.33.0":
version "4.33.0" version "4.33.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.33.0.tgz#a1e59036a3b53ae8430ceebf2a919dc7f9af6d72" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.33.0.tgz#a1e59036a3b53ae8430ceebf2a919dc7f9af6d72"
@ -1249,6 +1257,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.53.0.tgz#f79eca62b97e518ee124086a21a24f3be267026f" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.53.0.tgz#f79eca62b97e518ee124086a21a24f3be267026f"
integrity sha512-5kcDL9ZUIP756K6+QOAfPkigJmCPHcLN7Zjdz76lQWWDdzfOhZDTj1irs6gPBKiXx5/6O3L0+AvupAut3z7D2A== integrity sha512-5kcDL9ZUIP756K6+QOAfPkigJmCPHcLN7Zjdz76lQWWDdzfOhZDTj1irs6gPBKiXx5/6O3L0+AvupAut3z7D2A==
"@typescript-eslint/types@5.54.1":
version "5.54.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.54.1.tgz#29fbac29a716d0f08c62fe5de70c9b6735de215c"
integrity sha512-G9+1vVazrfAfbtmCapJX8jRo2E4MDXxgm/IMOF4oGh3kq7XuK3JRkOg6y2Qu1VsTRmWETyTkWt1wxy7X7/yLkw==
"@typescript-eslint/typescript-estree@4.33.0": "@typescript-eslint/typescript-estree@4.33.0":
version "4.33.0" version "4.33.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz#0dfb51c2908f68c5c08d82aefeaf166a17c24609" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz#0dfb51c2908f68c5c08d82aefeaf166a17c24609"
@ -1275,6 +1288,19 @@
semver "^7.3.7" semver "^7.3.7"
tsutils "^3.21.0" tsutils "^3.21.0"
"@typescript-eslint/typescript-estree@5.54.1":
version "5.54.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.54.1.tgz#df7b6ae05fd8fef724a87afa7e2f57fa4a599be1"
integrity sha512-bjK5t+S6ffHnVwA0qRPTZrxKSaFYocwFIkZx5k7pvWfsB1I57pO/0M0Skatzzw1sCkjJ83AfGTL0oFIFiDX3bg==
dependencies:
"@typescript-eslint/types" "5.54.1"
"@typescript-eslint/visitor-keys" "5.54.1"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/utils@5.53.0": "@typescript-eslint/utils@5.53.0":
version "5.53.0" version "5.53.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.53.0.tgz#e55eaad9d6fffa120575ffaa530c7e802f13bce8" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.53.0.tgz#e55eaad9d6fffa120575ffaa530c7e802f13bce8"
@ -1289,6 +1315,20 @@
eslint-utils "^3.0.0" eslint-utils "^3.0.0"
semver "^7.3.7" semver "^7.3.7"
"@typescript-eslint/utils@^5.10.0":
version "5.54.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.54.1.tgz#7a3ee47409285387b9d4609ea7e1020d1797ec34"
integrity sha512-IY5dyQM8XD1zfDe5X8jegX6r2EVU5o/WJnLu/znLPWCBF7KNGC+adacXnt5jEYS9JixDcoccI6CvE4RCjHMzCQ==
dependencies:
"@types/json-schema" "^7.0.9"
"@types/semver" "^7.3.12"
"@typescript-eslint/scope-manager" "5.54.1"
"@typescript-eslint/types" "5.54.1"
"@typescript-eslint/typescript-estree" "5.54.1"
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"
semver "^7.3.7"
"@typescript-eslint/visitor-keys@4.33.0": "@typescript-eslint/visitor-keys@4.33.0":
version "4.33.0" version "4.33.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz#2a22f77a41604289b7a186586e9ec48ca92ef1dd" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz#2a22f77a41604289b7a186586e9ec48ca92ef1dd"
@ -1305,6 +1345,14 @@
"@typescript-eslint/types" "5.53.0" "@typescript-eslint/types" "5.53.0"
eslint-visitor-keys "^3.3.0" eslint-visitor-keys "^3.3.0"
"@typescript-eslint/visitor-keys@5.54.1":
version "5.54.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.54.1.tgz#d7a8a0f7181d6ac748f4d47b2306e0513b98bf8b"
integrity sha512-q8iSoHTgwCfgcRJ2l2x+xCbu8nBlRAlsQ33k24Adj8eoVBE0f8dUeI+bAa8F84Mv05UGbAx57g2zrRsYIooqQg==
dependencies:
"@typescript-eslint/types" "5.54.1"
eslint-visitor-keys "^3.3.0"
"@wry/equality@^0.1.2": "@wry/equality@^0.1.2":
version "0.1.11" version "0.1.11"
resolved "https://registry.yarnpkg.com/@wry/equality/-/equality-0.1.11.tgz#35cb156e4a96695aa81a9ecc4d03787bc17f1790" resolved "https://registry.yarnpkg.com/@wry/equality/-/equality-0.1.11.tgz#35cb156e4a96695aa81a9ecc4d03787bc17f1790"
@ -2714,6 +2762,13 @@ eslint-plugin-import@^2.23.4:
resolve "^1.20.0" resolve "^1.20.0"
tsconfig-paths "^3.11.0" tsconfig-paths "^3.11.0"
eslint-plugin-jest@^27.2.1:
version "27.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.1.tgz#b85b4adf41c682ea29f1f01c8b11ccc39b5c672c"
integrity sha512-l067Uxx7ZT8cO9NJuf+eJHvt6bqJyz2Z29wykyEdz/OtmcELQl2MQGQLX8J94O1cSJWAwUSEvCjwjA7KEK3Hmg==
dependencies:
"@typescript-eslint/utils" "^5.10.0"
eslint-plugin-node@^11.1.0: eslint-plugin-node@^11.1.0:
version "11.1.0" version "11.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz#c95544416ee4ada26740a30474eefc5402dc671d" resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz#c95544416ee4ada26740a30474eefc5402dc671d"