-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemail.test.js
40 lines (35 loc) · 1.32 KB
/
email.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
'use strict';
const expect = require('chai').expect;
const validators = require('../src/common-validators');
describe('email', function() {
it('empty is valid', function() {
expect(validators.email(undefined)).to.be.undefined;
});
var values = [
[true, '[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, '[email protected]'],
[true, 'üñîçøðé@example.com'],
[true, '[email protected]'],
[false, 'foobar'],
[false, 'foo@bar'],
[false, 'abc.example.com'],
[false, 'a"b(c)d,e:f;g<h>i[j\\k][email protected]'],
[false, 'just"not"[email protected]'],
[false, 'this is"not\\[email protected]'],
[false, 'this\\ still\\"not\\\\[email protected]']
];
values.forEach(value => {
it(value[1] + ' is ' + (value[0] ? 'valid' : 'invalid'), function() {
if (value[0]) {
expect(validators.email(value[1])).to.be.undefined;
} else {
expect(validators.email(value[1])).to.have.property('error');
}
});
});
});