mirror of
https://github.com/hknsh/project-knedita.git
synced 2024-11-28 17:41:15 +00:00
Fixed small bug in create-user.ts
This commit is contained in:
parent
34604fce27
commit
c5e928aeec
4 changed files with 4 additions and 6 deletions
|
@ -22,7 +22,6 @@ A simple social media created with React Native and Express.
|
||||||
## Known problems
|
## Known problems
|
||||||
|
|
||||||
- Tests taking too long
|
- Tests taking too long
|
||||||
- Some tests will give error 401, for now just try until it works
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ async function userSignupService (username: string, email: string, password: str
|
||||||
return new Error('Missing fields')
|
return new Error('Missing fields')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^[a-zA-Z0-9_]{5,15}$/.test(username)) {
|
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')
|
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)) {
|
if (!validator.isEmail(email)) {
|
||||||
|
|
|
@ -8,7 +8,6 @@ let token = ''
|
||||||
describe('DELETE /user/delete', () => {
|
describe('DELETE /user/delete', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const user = await signUpNewUser()
|
const user = await signUpNewUser()
|
||||||
console.log(user)
|
|
||||||
token = user.token ?? ''
|
token = user.token ?? ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import userPayload from '../../interfaces/user'
|
||||||
|
|
||||||
async function signUpNewUser (): Promise<userPayload> {
|
async function signUpNewUser (): Promise<userPayload> {
|
||||||
// To avoid conflicts with existing usernames or emails
|
// To avoid conflicts with existing usernames or emails
|
||||||
const username = faker.internet.userName().toLowerCase()
|
const username = faker.internet.userName({ lastName: 'doe' }).toLowerCase()
|
||||||
const email = faker.internet.email().toLowerCase()
|
const email = faker.internet.email()
|
||||||
const password = faker.internet.password()
|
const password = faker.internet.password()
|
||||||
|
|
||||||
await request(app).post('/user/signup').send({
|
await request(app).post('/user/signup').send({
|
||||||
|
|
Loading…
Reference in a new issue