Email validation for @localhost address + tests
authorAntoine Musso <hashar@users.mediawiki.org>
Mon, 24 Jan 2011 21:13:55 +0000 (21:13 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Mon, 24 Jan 2011 21:13:55 +0000 (21:13 +0000)
See r80694 commit note

resources/mediawiki.util/mediawiki.util.js
resources/mediawiki.util/mediawiki.util.test.js

index 65936af..497bb33 100644 (file)
                                        // Domain first part
                                        '[' + rfc1034_ldh_str + ']+'
                                        +
-                                       // Second part and following are separated by a dot
-                                       '(?:\\.[' + rfc1034_ldh_str + ']+)+'
+                                       // Optional second part and following are separated by a dot
+                                       '(?:\\.[' + rfc1034_ldh_str + ']+)*'
                                        +
                                        // End of string
                                        '$',
index f99e8e4..33e2118 100644 (file)
                                                mw.test.addTest( 'typeof $.fn.makeCollapsible',
                                                        'function (string)' );
 
+                                               // Email validation
+                                               // TODO: import tests from PHPUnit test suite
+                                               mw.test.addHead( 'Email validation' );
+
+                                               mw.test.addTest( 'mw.util.validateEmail( "" )',
+                                                       'null (object)' );
+
+                                               mw.test.addTest( 'mw.util.validateEmail( "user@localhost" )',
+                                                       'true (boolean)' );
+
                                                // Run tests and compare results
                                                var     exec,
                                                        result,
 
        mediaWiki.test.init();
 
-} )(jQuery, mediaWiki);
\ No newline at end of file
+} )(jQuery, mediaWiki);