test( 'getRGB', function(){
- equals( typeof jQuery.colorUtil.getRGB(), 'undefined', 'No arguments' );
- equals( typeof jQuery.colorUtil.getRGB( '' ), 'undefined', 'Empty string' );
- same( jQuery.colorUtil.getRGB( [0, 100, 255] ), [0, 100, 255], 'Array' );
- same( jQuery.colorUtil.getRGB( 'rgb(0,100,255)' ), [0, 100, 255], 'Parse simple string' );
- same( jQuery.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [0, 100, 255], 'Parse simple string (whitespace)' );
- same( jQuery.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [0, 51, 102], 'Parse percentages string' );
- same( jQuery.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [0, 51, 102], 'Parse percentages string (whitespace)' );
- same( jQuery.colorUtil.getRGB( '#f2ddee' ), [242, 221, 238], 'Hex string: 6 char lowercase' );
- same( jQuery.colorUtil.getRGB( '#f2DDEE' ), [242, 221, 238], 'Hex string: 6 char uppercase' );
- same( jQuery.colorUtil.getRGB( '#f2DdEe' ), [242, 221, 238], 'Hex string: 6 char mixed' );
- same( jQuery.colorUtil.getRGB( '#eee' ), [238, 238, 238], 'Hex string: 3 char lowercase' );
- same( jQuery.colorUtil.getRGB( '#EEE' ), [238, 238, 238], 'Hex string: 3 char uppercase' );
- same( jQuery.colorUtil.getRGB( '#eEe' ), [238, 238, 238], 'Hex string: 3 char mixed' );
- same( jQuery.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [255, 255, 255], 'Zero rgba for Safari 3; Transparent (whitespace)' );
+ equal( typeof jQuery.colorUtil.getRGB(), 'undefined', 'No arguments' );
+ equal( typeof jQuery.colorUtil.getRGB( '' ), 'undefined', 'Empty string' );
+ deepEqual( jQuery.colorUtil.getRGB( [0, 100, 255] ), [0, 100, 255], 'Array' );
+ deepEqual( jQuery.colorUtil.getRGB( 'rgb(0,100,255)' ), [0, 100, 255], 'Parse simple string' );
+ deepEqual( jQuery.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [0, 100, 255], 'Parse simple string (whitespace)' );
+ deepEqual( jQuery.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [0, 51, 102], 'Parse percentages string' );
+ deepEqual( jQuery.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [0, 51, 102], 'Parse percentages string (whitespace)' );
+ deepEqual( jQuery.colorUtil.getRGB( '#f2ddee' ), [242, 221, 238], 'Hex string: 6 char lowercase' );
+ deepEqual( jQuery.colorUtil.getRGB( '#f2DDEE' ), [242, 221, 238], 'Hex string: 6 char uppercase' );
+ deepEqual( jQuery.colorUtil.getRGB( '#f2DdEe' ), [242, 221, 238], 'Hex string: 6 char mixed' );
+ deepEqual( jQuery.colorUtil.getRGB( '#eee' ), [238, 238, 238], 'Hex string: 3 char lowercase' );
+ deepEqual( jQuery.colorUtil.getRGB( '#EEE' ), [238, 238, 238], 'Hex string: 3 char uppercase' );
+ deepEqual( jQuery.colorUtil.getRGB( '#eEe' ), [238, 238, 238], 'Hex string: 3 char mixed' );
+ deepEqual( jQuery.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [255, 255, 255], 'Zero rgba for Safari 3; Transparent (whitespace)' );
// Perhaps this is a bug in colorUtil, but it is the current behaviour so, let's keep track
// would that ever chnge
- equals( typeof jQuery.colorUtil.getRGB( 'rgba(0,0,0,0)' ), 'undefined', 'Zero rgba without whitespace' );
+ equal( typeof jQuery.colorUtil.getRGB( 'rgba(0,0,0,0)' ), 'undefined', 'Zero rgba without whitespace' );
- same( jQuery.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' );
- same( jQuery.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (transparent)' );
- equals( typeof jQuery.colorUtil.getRGB( 'mediaWiki' ), 'undefined', 'Inexisting Color name' );
+ deepEqual( jQuery.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' );
+ deepEqual( jQuery.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (transparent)' );
+ equal( typeof jQuery.colorUtil.getRGB( 'mediaWiki' ), 'undefined', 'Inexisting Color name' );
});
};
ok( hsl, 'Basic return evaluation' );
- same( dualDecimals(hsl[0]) , 0.33, 'rgb(144, 238, 144): H 0.33' );
- same( dualDecimals(hsl[1]) , 0.73, 'rgb(144, 238, 144): S 0.73' );
- same( dualDecimals(hsl[2]) , 0.75, 'rgb(144, 238, 144): L 0.75' );
+ deepEqual( dualDecimals(hsl[0]) , 0.33, 'rgb(144, 238, 144): H 0.33' );
+ deepEqual( dualDecimals(hsl[1]) , 0.73, 'rgb(144, 238, 144): S 0.73' );
+ deepEqual( dualDecimals(hsl[2]) , 0.75, 'rgb(144, 238, 144): L 0.75' );
});
var rgb = jQuery.colorUtil.hslToRgb( 0.3, 0.7, 0.8 );
ok( rgb, 'Basic return evaluation' );
- same( Math.round(rgb[0]) , 183, 'hsl(0.3, 0.7, 0.8): R 183' );
- same( Math.round(rgb[1]) , 240, 'hsl(0.3, 0.7, 0.8): G 240' );
- same( Math.round(rgb[2]) , 168, 'hsl(0.3, 0.7, 0.8): B 168' );
+ deepEqual( Math.round(rgb[0]) , 183, 'hsl(0.3, 0.7, 0.8): R 183' );
+ deepEqual( Math.round(rgb[1]) , 240, 'hsl(0.3, 0.7, 0.8): G 240' );
+ deepEqual( Math.round(rgb[2]) , 168, 'hsl(0.3, 0.7, 0.8): B 168' );
});
var a = jQuery.colorUtil.getColorBrightness( 'red', +0.1 );
- equals( a, 'rgb(255,50,50)', 'Start with named color, brighten 10%' );
+ equal( a, 'rgb(255,50,50)', 'Start with named color, brighten 10%' );
var b = jQuery.colorUtil.getColorBrightness( 'rgb(200,50,50)', -0.2 );
- equals( b, 'rgb(118,29,29)', 'Start with rgb string, darken 10%' );
+ equal( b, 'rgb(118,29,29)', 'Start with rgb string, darken 10%' );
});
test( 'rawurlencode', function(){
- equals( mw.util.rawurlencode( 'Test:A & B/Here' ), 'Test%3AA%20%26%20B%2FHere' );
+ equal( mw.util.rawurlencode( 'Test:A & B/Here' ), 'Test%3AA%20%26%20B%2FHere' );
});
test( 'wikiUrlencode', function(){
- equals( mw.util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' );
+ equal( mw.util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' );
});
var a = mw.util.addCSS( '#bodyContent { visibility: hidden; }' );
ok( a, 'function works' );
- same( a.disabled, false, 'property "disabled" is available and set to false' );
+ deepEqual( a.disabled, false, 'property "disabled" is available and set to false' );
var $b = $('#bodyContent');
- equals( $b.css('visibility'), 'hidden', 'Added style properties are in effect.' );
+ equal( $b.css('visibility'), 'hidden', 'Added style properties are in effect.' );
});
var hrefA = mw.util.wikiGetlink( 'Sandbox' );
- equals( hrefA, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' );
+ equal( hrefA, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' );
var hrefB = mw.util.wikiGetlink( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' );
- equals( hrefB, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage', 'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' );
+ equal( hrefB, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage', 'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' );
});
test( 'tooltipAccessKey', function(){
- equals( typeof mw.util.tooltipAccessKeyPrefix, 'string', 'mw.util.tooltipAccessKeyPrefix must be a string' );
+ equal( typeof mw.util.tooltipAccessKeyPrefix, 'string', 'mw.util.tooltipAccessKeyPrefix must be a string' );
ok( mw.util.tooltipAccessKeyRegexp instanceof RegExp, 'mw.util.tooltipAccessKeyRegexp instance of RegExp' );
ok( mw.util.updateTooltipAccessKeys, 'mw.util.updateTooltipAccessKeys' );
test( '$content', function(){
ok( mw.util.$content instanceof jQuery, 'mw.util.$content instance of jQuery' );
- same( mw.util.$content.length, 1, 'mw.util.$content must have length of 1' );
+ deepEqual( mw.util.$content.length, 1, 'mw.util.$content must have length of 1' );
});
var b = mw.util.addPortletLink( "p-tb", "http://mediawiki.org/", "MediaWiki.org", "t-mworg", "Go to MediaWiki.org ", "m", "#t-rl" );
- equals( $(a).text(), 'ResourceLoader', 'Link contains correct text' );
- equals( $(b).next().text(), 'ResourceLoader', 'Link was inserted in correct nextnode position' );
+ equal( $(a).text(), 'ResourceLoader', 'Link contains correct text' );
+ equal( $(b).next().text(), 'ResourceLoader', 'Link was inserted in correct nextnode position' );
});
test( 'validateEmail', function(){
- same( mw.util.validateEmail( "" ), null, 'Empty string should return null' );
- same( mw.util.validateEmail( "user@localhost" ), true );
+ deepEqual( mw.util.validateEmail( "" ), null, 'Empty string should return null' );
+ deepEqual( mw.util.validateEmail( "user@localhost" ), true );
// testEmailWithCommasAreInvalids
- same( mw.util.validateEmail( "user,foo@example.org" ), false, 'Comma' );
- same( mw.util.validateEmail( "userfoo@ex,ample.org" ), false, 'Comma' );
+ deepEqual( mw.util.validateEmail( "user,foo@example.org" ), false, 'Comma' );
+ deepEqual( mw.util.validateEmail( "userfoo@ex,ample.org" ), false, 'Comma' );
// testEmailWithHyphens
- same( mw.util.validateEmail( "user-foo@example.org" ), true, 'Hyphen' );
- same( mw.util.validateEmail( "userfoo@ex-ample.org" ), true, 'Hyphen' );
+ deepEqual( mw.util.validateEmail( "user-foo@example.org" ), true, 'Hyphen' );
+ deepEqual( mw.util.validateEmail( "userfoo@ex-ample.org" ), true, 'Hyphen' );
});
test( 'isIPv6Address', function(){
// Based on IPTest.php > IPv6
- same( mw.util.isIPv6Address( "" ), false, 'Empty string is not an IP' );
- same( mw.util.isIPv6Address( ":fc:100::" ), false, 'IPv6 starting with lone ":"' );
- same( mw.util.isIPv6Address( "fc:100::" ), true );
- same( mw.util.isIPv6Address( "fc:100:a:d:1:e:ac::" ), true );
- same( mw.util.isIPv6Address( ":::" ), false );
- same( mw.util.isIPv6Address( "::0:" ), false );
+ deepEqual( mw.util.isIPv6Address( "" ), false, 'Empty string is not an IP' );
+ deepEqual( mw.util.isIPv6Address( ":fc:100::" ), false, 'IPv6 starting with lone ":"' );
+ deepEqual( mw.util.isIPv6Address( "fc:100::" ), true );
+ deepEqual( mw.util.isIPv6Address( "fc:100:a:d:1:e:ac::" ), true );
+ deepEqual( mw.util.isIPv6Address( ":::" ), false );
+ deepEqual( mw.util.isIPv6Address( "::0:" ), false );
});
test( 'isIPv4Address', function(){
// Based on IPTest.php > IPv4
- same( mw.util.isIPv4Address( "" ), false, 'Empty string is not an IP' );
- same( mw.util.isIPv4Address( "...." ), false );
- same( mw.util.isIPv4Address( "1.24.52.13" ), true );
+ deepEqual( mw.util.isIPv4Address( "" ), false, 'Empty string is not an IP' );
+ deepEqual( mw.util.isIPv4Address( "...." ), false );
+ deepEqual( mw.util.isIPv4Address( "1.24.52.13" ), true );
});
ok( window.jQuery, 'jQuery defined' );
ok( window.$j, '$j defined' );
- equals( window.$j, window.jQuery, '$j alias to jQuery' );
+ equal( window.$j, window.jQuery, '$j alias to jQuery' );
ok( window.mediaWiki, 'mediaWiki defined' );
ok( window.mw, 'mw defined' );
- equals( window.mw, window.mediaWiki, 'mw alias to mediaWiki' );
+ equal( window.mw, window.mediaWiki, 'mw alias to mediaWiki' );
});
test( 'jQuery.extend', function(){
- equals( $j.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' );
- equals( $j.trimRight( ' foo bar ' ), ' foo bar', 'trimRight' );
- equals( $j.ucFirst( 'foo'), 'Foo', 'ucFirst' );
+ equal( $j.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' );
+ equal( $j.trimRight( ' foo bar ' ), ' foo bar', 'trimRight' );
+ equal( $j.ucFirst( 'foo'), 'Foo', 'ucFirst' );
- equals( $j.escapeRE( '<!-- ([{+mW+}]) $^|?>' ),
+ equal( $j.escapeRE( '<!-- ([{+mW+}]) $^|?>' ),
'<!\\-\\- \\(\\[\\{\\+mW\\+\\}\\]\\) \\$\\^\\|\\?>', 'escapeRE - Escape specials' );
- equals( $j.escapeRE( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ),
+ equal( $j.escapeRE( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'escapeRE - Leave uppercase alone' );
- equals( $j.escapeRE( 'abcdefghijklmnopqrstuvwxyz' ),
+ equal( $j.escapeRE( 'abcdefghijklmnopqrstuvwxyz' ),
'abcdefghijklmnopqrstuvwxyz', 'escapeRE - Leave lowercase alone' );
- equals( $j.escapeRE( '0123456789' ), '0123456789', 'escapeRE - Leave numbers alone' );
+ equal( $j.escapeRE( '0123456789' ), '0123456789', 'escapeRE - Leave numbers alone' );
- same( $j.isDomElement( document.getElementById( 'qunit-header' ) ), true,
+ deepEqual( $j.isDomElement( document.getElementById( 'qunit-header' ) ), true,
'isDomElement: #qunit-header Node' );
- same( $j.isDomElement( document.getElementById( 'random-name' ) ), false,
+ deepEqual( $j.isDomElement( document.getElementById( 'random-name' ) ), false,
'isDomElement: #random-name (null)' );
- same( $j.isDomElement( document.getElementsByTagName( 'div' ) ), false,
+ deepEqual( $j.isDomElement( document.getElementsByTagName( 'div' ) ), false,
'isDomElement: getElementsByTagName Array' );
- same( $j.isDomElement( document.getElementsByTagName( 'div' )[0] ), true,
+ deepEqual( $j.isDomElement( document.getElementsByTagName( 'div' )[0] ), true,
'isDomElement: getElementsByTagName(..)[0] Node' );
- same( $j.isDomElement( $j( 'div' ) ), false,
+ deepEqual( $j.isDomElement( $j( 'div' ) ), false,
'isDomElement: jQuery object' );
- same( $j.isDomElement( $j( 'div' ).get(0) ), true,
+ deepEqual( $j.isDomElement( $j( 'div' ).get(0) ), true,
'isDomElement: jQuery object > Get node' );
- same( $j.isDomElement( document.createElement( 'div' ) ), true,
+ deepEqual( $j.isDomElement( document.createElement( 'div' ) ), true,
'isDomElement: createElement' );
- same( $j.isDomElement( { foo: 1 } ), false,
+ deepEqual( $j.isDomElement( { foo: 1 } ), false,
'isDomElement: Object' );
- equals( $j.isEmpty( 'string' ), false, 'isEmptry: "string"' );
- equals( $j.isEmpty( '0' ), true, 'isEmptry: "0"' );
- equals( $j.isEmpty( [] ), true, 'isEmptry: []' );
- equals( $j.isEmpty( {} ), true, 'isEmptry: {}' );
+ equal( $j.isEmpty( 'string' ), false, 'isEmptry: "string"' );
+ equal( $j.isEmpty( '0' ), true, 'isEmptry: "0"' );
+ equal( $j.isEmpty( [] ), true, 'isEmptry: []' );
+ equal( $j.isEmpty( {} ), true, 'isEmptry: {}' );
// Documented behaviour
- equals( $j.isEmpty( { length: 0 } ), true, 'isEmptry: { length: 0 }' );
+ equal( $j.isEmpty( { length: 0 } ), true, 'isEmptry: { length: 0 }' );
ok( $j.compareArray( [0, 'a', [], [2, 'b'] ], [0, "a", [], [2, "b"] ] ),
'compareArray: Two the same deep arrays' );
ok( mw.config.set( 'lipsum', 'Lorem ipsum' ), 'set: lipsum' );
ok( mw.config.exists( 'lipsum' ), 'exists: lipsum (existant)' );
- equals( mw.config.get( 'lipsum' ), 'Lorem ipsum', 'get: lipsum' );
- equals( mw.config.get( ['lipsum'] ).lipsum, 'Lorem ipsum', 'get: lipsum (multiple)' );
+ equal( mw.config.get( 'lipsum' ), 'Lorem ipsum', 'get: lipsum' );
+ equal( mw.config.get( ['lipsum'] ).lipsum, 'Lorem ipsum', 'get: lipsum (multiple)' );
});
var hello = mw.message( 'hello' );
ok( hello, 'hello: Instance of Message' );
- equals( hello.format, 'parse', 'Message property "format" (default value)' );
- equals( hello.key, 'hello', 'Message property "key" (currect key)' );
- same( hello.parameters, [], 'Message property "parameters" (default value)' );
+ equal( hello.format, 'parse', 'Message property "format" (default value)' );
+ equal( hello.key, 'hello', 'Message property "key" (currect key)' );
+ deepEqual( hello.parameters, [], 'Message property "parameters" (default value)' );
ok( hello.params, 'Message prototype "params"');
ok( hello.escaped, 'Message prototype "escaped"');
ok( hello.exists, 'Message prototype "exists"');
- equals( hello.toString(), 'Hello <b>awesome</b> world', 'Message.toString() test');
- equals( hello.escaped(), 'Hello <b>awesome</b> world', 'Message.escaped() test');
- same( hello.exists(), true, 'Message.exists() test');
+ equal( hello.toString(), 'Hello <b>awesome</b> world', 'Message.toString() test');
+ equal( hello.escaped(), 'Hello <b>awesome</b> world', 'Message.escaped() test');
+ deepEqual( hello.exists(), true, 'Message.exists() test');
- equals( mw.msg( 'random' ), '<random>', 'square brackets around inexistant messages' );
- equals( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'get message with default options' );
+ equal( mw.msg( 'random' ), '<random>', 'square brackets around inexistant messages' );
+ equal( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'get message with default options' );
// params, toString, parse, plain, escaped, exists
});
mw.loader.implement( 'is.awesome', [location.href.match(/[^#\?]*/)[0] + 'sample/awesome.js'], {}, {} );
mw.loader.using( 'is.awesome', function(){
start();
- same( window.awesome, true, 'Implementing a module, is the callback timed properly ?');
+ deepEqual( window.awesome, true, 'Implementing a module, is the callback timed properly ?');
}, function(){
start();
- same( 'mw.loader.using error callback fired', true, 'Implementing a module, is the callback timed properly ?');
+ deepEqual( 'mw.loader.using error callback fired', true, 'Implementing a module, is the callback timed properly ?');
});
});
test( 'mw.html', function(){
- equals( mw.html.escape( '<mw awesome="awesome" value=\'test\' />' ),
+ equal( mw.html.escape( '<mw awesome="awesome" value=\'test\' />' ),
'<mw awesome="awesome" value='test' />', 'html.escape()' );
- equals( mw.html.element( 'div' ), '<div/>', 'mw.html.element() DIV (simple)' );
+ equal( mw.html.element( 'div' ), '<div/>', 'mw.html.element() DIV (simple)' );
- equals( mw.html.element( 'div',
+ equal( mw.html.element( 'div',
{ id: 'foobar' } ),
'<div id="foobar"/>',
'mw.html.element() DIV (attribs)' );
- equals( mw.html.element( 'div',
+ equal( mw.html.element( 'div',
null, 'a' ),
'<div>a</div>',
'mw.html.element() DIV (content)' );
- equals( mw.html.element( 'a',
+ equal( mw.html.element( 'a',
{ href: 'http://mediawiki.org/w/index.php?title=RL&action=history' }, 'a' ),
'<a href="http://mediawiki.org/w/index.php?title=RL&action=history">a</a>',
'mw.html.element() DIV (attribs + content)' );