mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
remove empty string check since we do a length check on memeo & name
This commit is contained in:
parent
db1ed715ca
commit
a04d4d3985
@ -319,27 +319,6 @@ describe('Contribution Links', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns an error if name is an empty string', async () => {
|
|
||||||
jest.clearAllMocks()
|
|
||||||
await expect(
|
|
||||||
mutate({
|
|
||||||
mutation: createContributionLink,
|
|
||||||
variables: {
|
|
||||||
...variables,
|
|
||||||
name: '',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
).resolves.toEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
errors: [new GraphQLError('The name must be initialized')],
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('logs the error thrown', () => {
|
|
||||||
expect(logger.error).toBeCalledWith('The name must be initialized')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns an error if name is shorter than 5 characters', async () => {
|
it('returns an error if name is shorter than 5 characters', async () => {
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
@ -382,27 +361,6 @@ describe('Contribution Links', () => {
|
|||||||
expect(logger.error).toBeCalledWith('The value of name is too long', 101)
|
expect(logger.error).toBeCalledWith('The value of name is too long', 101)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns an error if memo is an empty string', async () => {
|
|
||||||
jest.clearAllMocks()
|
|
||||||
await expect(
|
|
||||||
mutate({
|
|
||||||
mutation: createContributionLink,
|
|
||||||
variables: {
|
|
||||||
...variables,
|
|
||||||
memo: '',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
).resolves.toEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
errors: [new GraphQLError('The memo must be initialized')],
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('logs the error thrown', () => {
|
|
||||||
expect(logger.error).toBeCalledWith('The memo must be initialized')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns an error if memo is shorter than 5 characters', async () => {
|
it('returns an error if memo is shorter than 5 characters', async () => {
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
await expect(
|
await expect(
|
||||||
|
|||||||
@ -40,20 +40,12 @@ export class ContributionLinkResolver {
|
|||||||
}: ContributionLinkArgs,
|
}: ContributionLinkArgs,
|
||||||
): Promise<ContributionLink> {
|
): Promise<ContributionLink> {
|
||||||
isStartEndDateValid(validFrom, validTo)
|
isStartEndDateValid(validFrom, validTo)
|
||||||
// TODO: this should be enforced by the schema.
|
|
||||||
if (!name) {
|
|
||||||
throw new LogError('The name must be initialized')
|
|
||||||
}
|
|
||||||
if (name.length < CONTRIBUTIONLINK_NAME_MIN_CHARS) {
|
if (name.length < CONTRIBUTIONLINK_NAME_MIN_CHARS) {
|
||||||
throw new LogError('The value of name is too short', name.length)
|
throw new LogError('The value of name is too short', name.length)
|
||||||
}
|
}
|
||||||
if (name.length > CONTRIBUTIONLINK_NAME_MAX_CHARS) {
|
if (name.length > CONTRIBUTIONLINK_NAME_MAX_CHARS) {
|
||||||
throw new LogError('The value of name is too long', name.length)
|
throw new LogError('The value of name is too long', name.length)
|
||||||
}
|
}
|
||||||
// TODO: this should be enforced by the schema.
|
|
||||||
if (!memo) {
|
|
||||||
throw new LogError('The memo must be initialized')
|
|
||||||
}
|
|
||||||
if (memo.length < MEMO_MIN_CHARS) {
|
if (memo.length < MEMO_MIN_CHARS) {
|
||||||
throw new LogError('The value of memo is too short', memo.length)
|
throw new LogError('The value of memo is too short', memo.length)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user