From c5e928aeecbe1f47bc7147d5ba8dbbb003a39cae Mon Sep 17 00:00:00 2001 From: CookieDasora Date: Thu, 29 Jun 2023 10:51:44 -0300 Subject: [PATCH] Fixed small bug in create-user.ts --- README.md | 1 - src/services/users/user-signup.ts | 4 ++-- src/tests/user/user-delete.spec.ts | 1 - src/tests/utils/create-user.ts | 4 ++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 727a103..38743a4 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ A simple social media created with React Native and Express. ## Known problems - Tests taking too long -- Some tests will give error 401, for now just try until it works ## License diff --git a/src/services/users/user-signup.ts b/src/services/users/user-signup.ts index bfd4115..59dc685 100644 --- a/src/services/users/user-signup.ts +++ b/src/services/users/user-signup.ts @@ -7,8 +7,8 @@ async function userSignupService (username: string, email: string, password: str return new Error('Missing fields') } - if (!/^[a-zA-Z0-9_]{5,15}$/.test(username)) { - return new Error('Username not allowed. Only alphanumerics characters (uppercase and lowercase words), underscore and it must be between 5 and 15 characters') + if (!/^[a-zA-Z0-9_.]{5,15}$/.test(username)) { + return new Error('Username not allowed. Only alphanumerics characters (uppercase and lowercase words), underscore, dot and it must be between 5 and 15 characters') } if (!validator.isEmail(email)) { diff --git a/src/tests/user/user-delete.spec.ts b/src/tests/user/user-delete.spec.ts index 7b268a5..a12b000 100644 --- a/src/tests/user/user-delete.spec.ts +++ b/src/tests/user/user-delete.spec.ts @@ -8,7 +8,6 @@ let token = '' describe('DELETE /user/delete', () => { beforeAll(async () => { const user = await signUpNewUser() - console.log(user) token = user.token ?? '' }) diff --git a/src/tests/utils/create-user.ts b/src/tests/utils/create-user.ts index 33887d7..8b5d157 100644 --- a/src/tests/utils/create-user.ts +++ b/src/tests/utils/create-user.ts @@ -5,8 +5,8 @@ import userPayload from '../../interfaces/user' async function signUpNewUser (): Promise { // To avoid conflicts with existing usernames or emails - const username = faker.internet.userName().toLowerCase() - const email = faker.internet.email().toLowerCase() + const username = faker.internet.userName({ lastName: 'doe' }).toLowerCase() + const email = faker.internet.email() const password = faker.internet.password() await request(app).post('/user/signup').send({