Fixed small bug in create-user.ts

This commit is contained in:
Hackntosh 2023-06-29 10:51:44 -03:00
parent 34604fce27
commit c5e928aeec
4 changed files with 4 additions and 6 deletions

View file

@ -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

View file

@ -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)) {

View file

@ -8,7 +8,6 @@ let token = ''
describe('DELETE /user/delete', () => {
beforeAll(async () => {
const user = await signUpNewUser()
console.log(user)
token = user.token ?? ''
})

View file

@ -5,8 +5,8 @@ import userPayload from '../../interfaces/user'
async function signUpNewUser (): Promise<userPayload> {
// 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({