Repository URL to install this package:
|
Version:
2.0.2 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/* eslint-disable max-statements */
const __1 = require("../"); // @todo - enable, finish, haven't run, meeting
describe('validators.email', () => {
/**
* @author https://en.wikipedia.org/wiki/Email_address#Valid_email_addresses
*/
it('allows valid emails', () => {
expect(__1.isEmail('nicklas@ansman.se')).toBeTruthy();
expect(__1.isEmail('NiCkLaS@AnSmAn.Se')).toBeTruthy();
expect(__1.isEmail('niceandsimple@example.com')).toBeTruthy();
expect(__1.isEmail('very.common@example.com')).toBeTruthy();
expect(__1.isEmail('a.little.lengthy.but.fine@dept.example.com')).toBeTruthy();
expect(__1.isEmail('disposable.style.email.with+symbol@example.com')).toBeTruthy();
expect(__1.isEmail('other.email-with-dash@example.com')).toBeTruthy();
expect(__1.isEmail('üñîçøðé@example.com')).toBeTruthy();
expect(__1.isEmail('foo@some.customtld')).toBeTruthy();
});
it('does not allow undefined values', () => {
expect(__1.isEmail(undefined)).toBeFalsy();
expect(__1.isEmail(undefined)).toBeFalsy();
});
it('does not not allow non strings', () => {
expect(__1.isEmail(3.14)).toBeFalsy();
expect(__1.isEmail(true)).toBeFalsy();
});
/**
* @author https://en.wikipedia.org/wiki/Email_address#Invalid_email_addresses
*/
it('does not allow `invalid` emails', () => {
const expected = false;
expect(__1.isEmail('')).toEqual(expected);
expect(__1.isEmail(' ')).toEqual(expected);
expect(__1.isEmail('foobar')).toEqual(expected);
expect(__1.isEmail('foo@bar')).toEqual(expected);
expect(__1.isEmail('abc.example.com')).toEqual(expected);
expect(__1.isEmail('a@b@c@example.com')).toEqual(expected);
expect(__1.isEmail('a"b(c)d,e:f;g<h>i[j\\k]l@example.com')).toEqual(expected);
expect(__1.isEmail('just"not"right@example.com')).toEqual(expected);
expect(__1.isEmail('this is"not\\allowed@example.com')).toEqual(expected);
expect(__1.isEmail('this\\ still\\"not\\\\allowed@example.com')).toEqual(expected);
});
}); //# sourceMappingURL=email.test.js.map