From 0c5276fd39f9786d64e616eadda2e284246c81a6 Mon Sep 17 00:00:00 2001 From: Alessandro Magionami Date: Fri, 5 Jul 2024 11:26:46 +0200 Subject: [PATCH] chore(user-emails): use random email in tests --- .../core/tests/integration/user-emails.spec.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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) }) }) })