-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
6 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ import EmailAdjuster from "libs/EmailAdjuster"; | |
describe("default", testDefault); | ||
describe("empty", testEmpty); | ||
describe("allowEmpty", testAllowEmpty); | ||
describe("maxLength", testMaxLength); | ||
describe("pattern", testPattern); | ||
describe("email", testEmail); | ||
} | ||
|
@@ -52,6 +53,39 @@ function testAllowEmpty() | |
}); | ||
} | ||
|
||
function testMaxLength() | ||
{ | ||
const objEmailAdjuster = new EmailAdjuster(); | ||
it("should be OK", () => | ||
{ | ||
const values = [ | ||
"1234567890123456789012345678901234567890123456789012345678901234@example.com", | ||
"user@12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901.com", | ||
"1234567890123456789012345678901234567890123456789012345678901234@12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901.com", | ||
]; | ||
for(const value of values) | ||
{ | ||
expect(objEmailAdjuster.adjust(value)).toEqual(value); | ||
} | ||
}); | ||
it("should cause error(s)", () => | ||
{ | ||
const values = [ | ||
"12345678901234567890123456789012345678901234567890123456789012345@example.com", | ||
"user@123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012.com", | ||
"12345678901234567890123456789012345678901234567890123456789012345@12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901.com", | ||
"1234567890123456789012345678901234567890123456789012345678901234@123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012.com", | ||
]; | ||
for(const value of values) | ||
{ | ||
expect(() => | ||
{ | ||
objEmailAdjuster.adjust(value); | ||
}).toThrow(CAUSE.MAX_LENGTH); | ||
} | ||
}); | ||
} | ||
|
||
function testPattern() | ||
{ | ||
const objEmailAdjuster = new EmailAdjuster().pattern(/^\w+@([\w-]+\.)+\w+$/); | ||
|
@@ -81,9 +115,11 @@ function testEmail() | |
"user+mailbox/[email protected]", | ||
"!#$%&'*+-/=?^_`.{|}[email protected]", | ||
|
||
// quoted-pair | ||
// quoted-string | ||
"\"Fred\\\"Bloggs\"@example.com", | ||
"\"Joe.\\\\Blow\"@example.com", | ||
"\"...\"@example.com", | ||
"\"(@_@) >_< ...(o;_;)o\"@example.com", | ||
|
||
// domain | ||
"[email protected]", | ||
|