Adding QUnit tests for mw.loader (Follow-up r88053)
authorKrinkle <krinkle@users.mediawiki.org>
Sat, 14 May 2011 12:48:38 +0000 (12:48 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Sat, 14 May 2011 12:48:38 +0000 (12:48 +0000)
resources/mediawiki.action/mediawiki.action.history.js
resources/test/unit/mediawiki.util/mediawiki.util.js
resources/test/unit/mediawiki/mediawiki.js

index 6674590..60cec16 100644 (file)
@@ -13,7 +13,7 @@ jQuery( function( $ ) {
                $lis.removeClass( 'selected' );
                $lis.each( function() {
                        var $this = $(this);
-                       var $inputs = $this.find( 'input[type=radio]' );
+                       var $inputs = $this.find( 'input[type="radio"]' );
                        if ( $inputs.length !== 2 ) {
                                return true;
                        }
@@ -47,7 +47,7 @@ jQuery( function( $ ) {
                });
                return true;
        };
-       
+
        var fixCompare = function () {
                var $diffList = $( '#pagehistory' ),
                 $histForm = $( '#mw-history-compare' ),
@@ -59,21 +59,22 @@ jQuery( function( $ ) {
                }
                var copyAttrs = ['title', 'accesskey'];
                $buttons.each(function() {
+                       console.log(this);
                        var $button = $(this),
                                $compareLink= $( '<a></a>', {
-                               'class': 'compare-link',
-                               'text': $button.val()
-                       }).button();
-                       $.each(copyAttrs, function(i, name) {
-                               var val = $button.attr(name);
+                                       'class': 'compare-link',
+                                       'text': $button.val()
+                               }).button();
+                       $.each( copyAttrs, function( i, name ) {
+                               var val = $button.attr( name );
                                if (val) {
-                                       $compareLink.attr(name, val);
+                                       $compareLink.attr( name, val );
                                }
                        });
-                       $button.replaceWith($compareLink);
+                       $button.replaceWith( $compareLink );
                });
                var updateCompare = function() {
-                       var $radio = $histForm.find( 'input[type=radio]:checked' );
+                       var $radio = $histForm.find( 'input[type="radio"]:checked' );
                        var genLink = mw.config.get( 'wgScript' )
                                + '?title=' + mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) )
                                + '&diff=' + $radio.eq(0).val()
index 06244a3..826f78a 100644 (file)
@@ -109,8 +109,6 @@ test( 'validateEmail', function(){
 
 });
 
-
-
 test( 'isIPv6Address', function(){
 
        // Based on IPTest.php > IPv6
@@ -123,7 +121,6 @@ test( 'isIPv6Address', function(){
 
 });
 
-
 test( 'isIPv4Address', function(){
 
        // Based on IPTest.php > IPv4
index b602893..a50107b 100644 (file)
@@ -128,16 +128,18 @@ test( 'mw.user', function(){
 });
 
 test( 'mw.loader', function(){
+       expect(1);
 
-       ok( mw.loader, 'loader defined' );
-       ok( mw.loader.work, 'loader.work defined' );
-       ok( mw.loader.register, 'loader.register defined' );
-       ok( mw.loader.implement, 'loader.implement defined' );
-       ok( mw.loader.using, 'loader.using defined' );
-       ok( mw.loader.load, 'loader.load defined' );
-       ok( mw.loader.go, 'loader.go defined' );
-       ok( mw.loader.state, 'loader.state defined' );
-       ok( mw.loader.version, 'loader.version defined' );
+       stop();
+       
+       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 ?');
+       }, function(){
+               start();
+               same( 'mw.loader.using error callback fired', true, 'Implementing a module, is the callback timed properly ?');
+       });
 
 });