mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
fix: setup Jest with TS
This commit is contained in:
1 parent
557af91d4b
commit
a18e0d9b68
12 files changed
+45
-9
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { isValidEmail, isValidUsername } from '../src/auth'
|
||||
|
||||
test('check valid username', () => {
|
||||
const valid = ['alex', 'alex123', 'john_doe', 'john-doe', 'rudeus']
|
||||
|
||||
const invalid = ['root', 'admin', '12michael', 'Justin', 'testUser']
|
||||
|
||||
valid.forEach((username) => {
|
||||
expect(isValidUsername(username)).toBe(true)
|
||||
})
|
||||
|
||||
invalid.forEach((username) => {
|
||||
expect(isValidUsername(username)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
test('check valid email', () => {
|
||||
const validEmails = [
|
||||
'user@example.com',
|
||||
'user.name@example.co.uk',
|
||||
'user1234@email.domain',
|
||||
'user+tag@example.net',
|
||||
'user@subdomain.example.com',
|
||||
'user@123.45.67.89',
|
||||
]
|
||||
|
||||
const invalidEmails = [
|
||||
'user@.com',
|
||||
'@example.com',
|
||||
'user@-invalid-domain.com',
|
||||
'user@.123',
|
||||
'user@.123.45.67',
|
||||
]
|
||||
|
||||
validEmails.forEach((email) => {
|
||||
expect(isValidEmail(email)).toBe(true)
|
||||
})
|
||||
|
||||
invalidEmails.forEach((email) => {
|
||||
expect(isValidEmail(email)).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user