forked from manishsaraan/email-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
100 lines (93 loc) · 3.91 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const expect = require('chai').expect;
const validator = require(".");
const validSupported =
[
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@letters-in-local.org",
"&'*+-./=?^_{}[email protected]",
"mixed-1234-in-{+^}[email protected]",
"the-total-length@of-an-entire-address.cannot-be-longer-than-two-hundred-and-fifty-four-characters.and-this-address-is-254-characters-exactly.so-it-should-be-valid.and-im-going-to-add-some-more-words-here.to-increase-the-lenght-blah-blah-blah-blah-bla.org",
"the-character-limit@for-each-part.of-the-domain.is-sixty-three-characters.this-is-exactly-sixty-three-characters-so-it-is-valid-blah-blah.com",
"backticks`are`[email protected]",
"t119037jskc_ihndkdoz@aakctgajathzffcsuqyjhgjuxnuulgnhxtnbquwtgxljfayeestsjdbalthtddy.lgtmsdhywswlameglunsaplsblljavswxrltovagexhtttodqedmicsekvpmpuu.pgjvdmvzyltpixvalfbktnnpjyjqswbfvtpbfsngqtmhgamhrbqqvyvlhqigggv.nxqglspfbwdhtfpibcrccvctmoxuxwlunghhwacjtrclgirrgppvshxvrzkoifl",
];
const validUnsupported =
[
"\"quoted\"@sld.com",
"\"\\e\\s\\c\\a\\p\\e\\d\"@sld.com",
"\"[email protected]\"@sld.com",
"\"escaped\\\"quote\"@sld.com",
"\"back\\slash\"@sld.com",
"bracketed-IP-instead-of-domain@[127.0.0.1]"
];
const invalidSupported =
[
"@missing-local.org",
"! #$%`|@invalid-characters-in-local.org",
"(),:;`|@more-invalid-characters-in-local.org",
"<>@[]\\`|@even-more-invalid-characters-in-local.org",
"partially.\"quoted\"@sld.com",
"the-local-part-is-invalid-if-it-is-longer-than-sixty-four-characters@sld.net",
"invalid-characters-in-sld@! \"#$%(),/;<>_[]`|.org",
"missing-dot-before-tld@com",
"missing-tld@sld.",
"invalid",
"the-total-length@of-an-entire-address.cannot-be-longer-than-two-hundred-and-fifty-six-characters.and-this-address-is-257-characters-exactly.so-it-should-be-invalid.and-im-going-to-add-some-more-words-here.to-increase-the-lenght-blah-blah-blah-blah-blah-.org",
"the-character-limit@for-each-part.of-the-domain.is-sixty-three-characters.this-is-exactly-sixty-four-characters-so-it-is-invalid-blah-blah.com",
"missing-at-sign.net",
"[email protected]:25",
"double@a@com",
"",
"tr119037jskc_ihndkdoz@d.aakctgajathzffcsuqyjhgjuxnuulgnhxtnbquwtgxljfayeestsjdbalthtddy.lgtmsdhywswlameglunsaplsblljavswxrltovagexhtttodqedmicsekvpmpuu.pgjvdmvzyltpixvalfbktnnpjyjqswbfvtpbfsngqtmhgamhrbqqvyvlhqigggv.nxqglspfbwdhtfpibcrccvctmoxuxwlunghhwacjtrclgirrgppvshxvrzkoifl",
];
describe('TEST EMAILS AGAINST VALIDATOR', () => {
it('Should Be Valid', () => {
validSupported.forEach( email => {
expect(validator.validate(email)).to.equal(true);
});
});
it('Should Be Invalid', () => {
invalidSupported.forEach( email => {
expect(validator.validate(email)).to.equal(false);
});
});
it('Should Be Invalid(UnSupported By Module)', () => {
validUnsupported.forEach( email => {
expect(validator.validate(email)).to.equal(false);
});
});
});