Merge "Add unit tests for mw.format()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 24 Nov 2015 20:48:18 +0000 (20:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 24 Nov 2015 20:48:18 +0000 (20:48 +0000)
1  2 
tests/qunit/suites/resources/mediawiki/mediawiki.test.js

                this.restoreWarnings();
        } );
  
+       QUnit.test( 'mw.format', 2, function ( assert ) {
+               assert.equal(
+                       mw.format( 'Format $1 $2', 'foo', 'bar' ),
+                       'Format foo bar',
+                       'Simple parameters'
+               );
+               assert.equal(
+                       mw.format( 'Format $1 $2' ),
+                       'Format $1 $2',
+                       'Missing parameters'
+               );
+       } );
        QUnit.test( 'mw.Map', 35, function ( assert ) {
                var arry, conf, funky, globalConf, nummy, someValues;
  
                } );
        } );
  
 -      QUnit.asyncTest( 'mw.loader.using( .. ).promise', 2, function ( assert ) {
 +      QUnit.asyncTest( 'mw.loader.using( .. ) Promise', 2, function ( assert ) {
                var isAwesomeDone;
  
                mw.loader.testCallback = function () {
        } );
  
        // @import (bug 31676)
 -      QUnit.asyncTest( 'mw.loader.implement( styles has @import)', 7, function ( assert ) {
 +      QUnit.asyncTest( 'mw.loader.implement( styles has @import )', 7, function ( assert ) {
                var isJsExecuted, $element;
  
                mw.loader.implement(
                } );
        } );
  
 -      QUnit.test( 'mw.loader erroneous indirect dependency', 4, function ( assert ) {
 +      QUnit.test( 'mw.loader with broken indirect dependency', 4, function ( assert ) {
                // don't emit an error event
                this.sandbox.stub( mw, 'track' );
  
                assert.strictEqual( mw.track.callCount, 1 );
        } );
  
 +      QUnit.test( 'mw.loader with circular dependency', 1, function ( assert ) {
 +              mw.loader.register( [
 +                      [ 'test.circle1', '0', [ 'test.circle2' ] ],
 +                      [ 'test.circle2', '0', [ 'test.circle3' ] ],
 +                      [ 'test.circle3', '0', [ 'test.circle1' ] ]
 +              ] );
 +              assert.throws( function () {
 +                      mw.loader.using( 'test.circle3' );
 +              }, /Circular/, 'Detect circular dependency' );
 +      } );
 +
        QUnit.test( 'mw.loader out-of-order implementation', 9, function ( assert ) {
                mw.loader.register( [
                        [ 'test.module4', '0' ],