-
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from kazizi55/feature/fix-email-regex
fix: improve email regex
- Loading branch information
Showing
2 changed files
with
16 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,32 +4,31 @@ import { email } from './email.ts'; | |
describe('email', () => { | ||
test('should pass only emails', () => { | ||
const validate = email(); | ||
|
||
const value1 = '[email protected]'; | ||
expect(validate(value1).output).toBe(value1); | ||
const value2 = 'firstname.lastname@example.com'; | ||
const value2 = '1234567890@example.com'; | ||
expect(validate(value2).output).toBe(value2); | ||
const value3 = 'email@subdomain.example.com'; | ||
const value3 = '_______@example.com'; | ||
expect(validate(value3).output).toBe(value3); | ||
const value4 = 'firstname+[email protected]'; | ||
const value4 = 'firstname.[email protected]'; | ||
expect(validate(value4).output).toBe(value4); | ||
const value5 = '[email protected]'; | ||
const value5 = '[email protected]'; | ||
expect(validate(value5).output).toBe(value5); | ||
const value6 = '“email”@example.com'; | ||
const value6 = 'firstname+lastname@example.com'; | ||
expect(validate(value6).output).toBe(value6); | ||
const value7 = '1234567890@example.com'; | ||
const value7 = 'email@aaa-bbb.com'; | ||
expect(validate(value7).output).toBe(value7); | ||
const value8 = 'email@example-one.com'; | ||
const value8 = 'email@example.name'; | ||
expect(validate(value8).output).toBe(value8); | ||
const value9 = '_______@example.com'; | ||
const value9 = 'email@example.co.uk'; | ||
expect(validate(value9).output).toBe(value9); | ||
const value10 = 'email@example.name'; | ||
const value10 = 'email@subdomain.example.com'; | ||
expect(validate(value10).output).toBe(value10); | ||
const value11 = 'email@example.co.uk'; | ||
const value11 = 'email@subdomain.aaa-bbb.com'; | ||
expect(validate(value11).output).toBe(value11); | ||
const value12 = 'firstname-lastname@example.com'; | ||
const value12 = 'email@subdomain.example.co.uk'; | ||
expect(validate(value12).output).toBe(value12); | ||
const value13 = '[email protected]'; | ||
expect(validate(value13).output).toBe(value13); | ||
|
||
expect(validate('plainaddress').issues).toBeTruthy(); | ||
expect(validate('#@%^%#$@#$@#.com').issues).toBeTruthy(); | ||
|
@@ -40,11 +39,11 @@ describe('email', () => { | |
expect(validate('[email protected]').issues).toBeTruthy(); | ||
expect(validate('[email protected]').issues).toBeTruthy(); | ||
expect(validate('[email protected]').issues).toBeTruthy(); | ||
// FIXME: expect(validate('あいうえお@example.com').issues).toBeTruthy(); | ||
expect(validate('あいうえお@example.com').issues).toBeTruthy(); | ||
expect(validate('[email protected] (Joe Smith)').issues).toBeTruthy(); | ||
expect(validate('email@example').issues).toBeTruthy(); | ||
// FIXME: expect(validate('[email protected]').issues).toBeTruthy(); | ||
// FIXME: expect(validate('[email protected]').issues).toBeTruthy(); | ||
expect(validate('[email protected]').issues).toBeTruthy(); | ||
expect(validate('[email protected]').issues).toBeTruthy(); | ||
expect(validate('[email protected]').issues).toBeTruthy(); | ||
expect(validate('[email protected]').issues).toBeTruthy(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters