diff --git a/packages/server/modules/core/tests/integration/user-emails.spec.ts b/packages/server/modules/core/tests/integration/user-emails.spec.ts index f46ac41d7..8d1149489 100644 --- a/packages/server/modules/core/tests/integration/user-emails.spec.ts +++ b/packages/server/modules/core/tests/integration/user-emails.spec.ts @@ -4,6 +4,11 @@ import { beforeEachContext } from '@/test/hooks' import { expect } from 'chai' import { getUserByEmail } from '../../repositories/users' import { UserRecord } from '../../helpers/types' +import crs from 'crypto-random-string' + +function createRandomEmail() { + return `${crs({ length: 6 })}@example.org` +} describe('Core @user-emails', () => { before(async () => { @@ -15,27 +20,29 @@ describe('Core @user-emails', () => { }) it('should return user if user-email does not exist', async () => { + const email = createRandomEmail() await createUser({ name: 'John Doe', - email: 'test@example.org', + email, password: 'sn3aky-1337-b1m' }) const user = (await getUserByEmail('test@example.org')) as UserRecord expect(user.name).to.eq('John Doe') - expect(user.email).to.eq('test@example.org') + expect(user.email).to.eq(email) }) it('should return user merged with user-email', async () => { + const email = createRandomEmail() await createUser({ name: 'John Doe', - email: 'test1@example.org', + email, password: 'sn3aky-1337-b1m' }) - const user = (await getUserByEmail('test@example.org')) as UserRecord + const user = (await getUserByEmail(email)) as UserRecord expect(user.name).to.eq('John Doe') - expect(user.email).to.eq('test@example.org') + expect(user.email).to.eq(email) }) }) })