diff options
author | Joseph Frazer <joseph.frazer@ryansg.com> | 2019-09-12 09:08:47 -0400 |
---|---|---|
committer | Joseph Frazer <joseph.frazer@ryansg.com> | 2019-09-12 09:30:23 -0400 |
commit | 28f938853a60ee9d035ee66036314b93cf4d1a12 (patch) | |
tree | 9a095b2101f970749f90dfc1556f71d3d8a3f198 /test | |
parent | 27d570578d281fc43b2d7386ff6a440bc9a65e92 (diff) | |
download | liza-28f938853a60ee9d035ee66036314b93cf4d1a12.tar.gz liza-28f938853a60ee9d035ee66036314b93cf4d1a12.tar.bz2 liza-28f938853a60ee9d035ee66036314b93cf4d1a12.zip |
[DEV-5657] Check for TLD in email addresses
The DocuSign service rejects email addresses without a TLD, even though
they are valid.
Diffstat (limited to 'test')
-rw-r--r-- | test/validate/formatter/EmailFormatterTest.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/validate/formatter/EmailFormatterTest.js b/test/validate/formatter/EmailFormatterTest.js new file mode 100644 index 0000000..c451f32 --- /dev/null +++ b/test/validate/formatter/EmailFormatterTest.js @@ -0,0 +1,63 @@ +/** + * @license + * StringFormat formatter test + * + * Copyright (C) 2010-2019 R-T Specialty, LLC. + * + * This file is part of liza. + * + * liza is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +var liza = require( '../../../' ), + Sut = liza.validate.formatter.EmailFormatter, + assert = require( 'assert' ); + + +describe( 'validate.formatter.StringFormat', function() +{ + // test email addresses from + // https://blogs.msdn.microsoft.com/testing123/2009/02/06/email-address-test-cases/ + [ + "email@domain.com", + "firstname.lastname@domain.com", + "email@subdomain.domain.com", + "firstname+lastname@domain.com", + 'email"@domain.com', + "1234567890@domain.com", + "email@domain-one.com", + "_______@domain.com", + "email@domain.name", + "email@domain.co.jp", + "firstname-lastname@domain.com", + ].forEach( email_address => assert.equal( Sut.parse( email_address ), email_address ) ); + + [ + "", + "plainaddress", + "#@%^%#$@#$@#.com", + "@domain.com", + "Joe Smith <email@domain.com>", + "email.domain.com", + // "email@domain@domain.com", + ".email@domain.com", + "email.@domain.com", + "email..email@domain.com", + "あいうえお@domain.com", + "email@domain.com (Joe Smith)", + "email@domain", + "email@-domain.com", + "email@domain..com", + ].forEach( email_address => assert.throws( () => Sut.parse( email_address ), Error ) ); +} ); |