mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
test that existing emails do not throw anymore
This commit is contained in:
parent
78b8d18c4e
commit
88de09b1ba
@ -33,7 +33,9 @@ const sendPasswordResetMail = async (resolve, root, args, context, resolveInfo)
|
||||
const sendEmailVerificationMail = async (resolve, root, args, context, resolveInfo) => {
|
||||
const response = await resolve(root, args, context, resolveInfo)
|
||||
const { email, nonce, name } = response
|
||||
if (nonce) {
|
||||
await sendMail(emailVerificationTemplate({ email, variables: { nonce, name } }))
|
||||
}
|
||||
delete response.nonce
|
||||
return response
|
||||
}
|
||||
|
||||
@ -40,7 +40,9 @@ export default {
|
||||
}
|
||||
|
||||
// check email does not belong to anybody
|
||||
await existingEmailAddress({ args, context })
|
||||
const existingEmail = await existingEmailAddress({ args, context })
|
||||
if (existingEmail && existingEmail.alreadyExistingEmail && existingEmail.user)
|
||||
return existingEmail.alreadyExistingEmail
|
||||
|
||||
const nonce = generateNonce()
|
||||
const {
|
||||
|
||||
@ -134,11 +134,17 @@ describe('AddEmailAddress', () => {
|
||||
})
|
||||
|
||||
describe('but if another user owns an `EmailAddress` already with that email', () => {
|
||||
it('throws UserInputError because of unique constraints', async () => {
|
||||
it('does not throw UserInputError', async () => {
|
||||
await Factory.build('user', {}, { email: 'new-email@example.org' })
|
||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||
data: { AddEmailAddress: null },
|
||||
errors: [{ message: 'A user account with this email already exists.' }],
|
||||
data: {
|
||||
AddEmailAddress: {
|
||||
createdAt: expect.any(String),
|
||||
verifiedAt: null,
|
||||
email: 'new-email@example.org',
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -118,9 +118,9 @@ describe('Signup', () => {
|
||||
await emailAddress.relateTo(user, 'belongsTo')
|
||||
})
|
||||
|
||||
it('throws UserInputError error because of unique constraint violation', async () => {
|
||||
it('does not throw UserInputError error', async () => {
|
||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||
errors: [{ message: 'A user account with this email already exists.' }],
|
||||
data: { Signup: { email: 'someuser@example.org' } },
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user