Index: trunk/phase3/resources/test/unit/mediawiki.util/mediawiki.util.js |
— | — | @@ -108,3 +108,27 @@ |
109 | 109 | same( mw.util.validateEmail( "userfoo@ex-ample.org" ), true, 'Hyphen' ); |
110 | 110 | |
111 | 111 | }); |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +test( 'isIPv6Address', function(){ |
| 116 | + |
| 117 | + // Based on IPTest.php > IPv6 |
| 118 | + same( mw.util.isIPv6Address( "" ), false, 'Empty string is not an IP' ); |
| 119 | + same( mw.util.isIPv6Address( ":fc:100::" ), false, 'IPv6 starting with lone ":"' ); |
| 120 | + same( mw.util.isIPv6Address( "fc:100::" ), true ); |
| 121 | + same( mw.util.isIPv6Address( "fc:100:a:d:1:e:ac::" ), true ); |
| 122 | + same( mw.util.isIPv6Address( ":::" ), false ); |
| 123 | + same( mw.util.isIPv6Address( "::0:" ), false ); |
| 124 | + |
| 125 | +}); |
| 126 | + |
| 127 | + |
| 128 | +test( 'isIPv4Address', function(){ |
| 129 | + |
| 130 | + // Based on IPTest.php > IPv4 |
| 131 | + same( mw.util.isIPv4Address( "" ), false, 'Empty string is not an IP' ); |
| 132 | + same( mw.util.isIPv4Address( "...." ), false ); |
| 133 | + same( mw.util.isIPv4Address( "1.24.52.13" ), true ); |
| 134 | + |
| 135 | +}); |