/**
* @param {Function[]} tasks List of functions that perform tasks
* that may be asynchronous. Invoke the callback parameter when done.
- * @param {Function} complete Called when all tasks are done, or when the sequence is aborted.
*/
- function process( tasks, complete ) {
+ function process( tasks ) {
/*jshint latedef:false */
function abort() {
tasks.splice( 0, tasks.length );
} else {
// Remove tasks list to indicate the process is final.
tasks = null;
- complete();
}
}
next();
mw.user.options.set( 'gender', originalGender );
} );
+ QUnit.test( 'Case changing', 8, function ( assert ) {
+ mw.messages.set( 'to-lowercase', '{{lc:thIS hAS MEsSed uP CapItaliZatiON}}' );
+ assert.equal( formatParse( 'to-lowercase' ), 'this has messed up capitalization', 'To lowercase' );
+
+ mw.messages.set( 'to-caps', '{{uc:thIS hAS MEsSed uP CapItaliZatiON}}' );
+ assert.equal( formatParse( 'to-caps' ), 'THIS HAS MESSED UP CAPITALIZATION', 'To caps' );
+
+ mw.messages.set( 'uc-to-lcfirst', '{{lcfirst:THis hAS MEsSed uP CapItaliZatiON}}' );
+ mw.messages.set( 'lc-to-lcfirst', '{{lcfirst:thIS hAS MEsSed uP CapItaliZatiON}}' );
+ assert.equal( formatParse( 'uc-to-lcfirst' ), 'tHis hAS MEsSed uP CapItaliZatiON', 'Lcfirst caps' );
+ assert.equal( formatParse( 'lc-to-lcfirst' ), 'thIS hAS MEsSed uP CapItaliZatiON', 'Lcfirst lowercase' );
+
+ mw.messages.set( 'uc-to-ucfirst', '{{ucfirst:THis hAS MEsSed uP CapItaliZatiON}}' );
+ mw.messages.set( 'lc-to-ucfirst', '{{ucfirst:thIS hAS MEsSed uP CapItaliZatiON}}' );
+ assert.equal( formatParse( 'uc-to-ucfirst' ), 'THis hAS MEsSed uP CapItaliZatiON', 'Ucfirst caps' );
+ assert.equal( formatParse( 'lc-to-ucfirst' ), 'ThIS hAS MEsSed uP CapItaliZatiON', 'Ucfirst lowercase' );
+
+ mw.messages.set( 'mixed-to-sentence', '{{ucfirst:{{lc:thIS hAS MEsSed uP CapItaliZatiON}}}}' );
+ assert.equal( formatParse( 'mixed-to-sentence' ), 'This has messed up capitalization', 'To sentence case' );
+ mw.messages.set( 'all-caps-except-first', '{{lcfirst:{{uc:thIS hAS MEsSed uP CapItaliZatiON}}}}' );
+ assert.equal( formatParse( 'all-caps-except-first' ), 'tHIS HAS MESSED UP CAPITALIZATION', 'To opposite sentence case' );
+ } );
+
QUnit.test( 'Grammar', 2, function ( assert ) {
assert.equal( formatParse( 'grammar-msg' ), 'Przeszukaj Wiki', 'Grammar Test with sitename' );
mw.messages.set( mw.libs.phpParserData.messages );
var tasks = $.map( mw.libs.phpParserData.tests, function ( test ) {
return function ( next, abort ) {
+ var done = assert.async();
getMwLanguage( test.lang )
.then( function ( langClass ) {
mw.config.set( 'wgUserLanguage', test.lang );
}, function () {
assert.ok( false, 'Language "' + test.lang + '" failed to load.' );
} )
+ .then( done, done )
.then( next, abort );
};
} );
- QUnit.stop();
- process( tasks, QUnit.start );
+ process( tasks );
} );
QUnit.test( 'Links', 14, function ( assert ) {
message[ format ]();
assert.strictEqual( outerCalled, shouldCall, 'Outer function called for ' + key );
assert.strictEqual( innerCalled, shouldCall, 'Inner function called for ' + key );
+ delete mw.messages[ format ];
}
verifyGetMessageFunction( 'curly-brace', 'parse', true );
mw.messages.set( 'formatnum-msg-int', '{{formatnum:$1|R}}' );
var queue = $.map( formatnumTests, function ( test ) {
return function ( next, abort ) {
+ var done = assert.async();
getMwLanguage( test.lang )
.then( function ( langClass ) {
mw.config.set( 'wgUserLanguage', test.lang );
}, function () {
assert.ok( false, 'Language "' + test.lang + '" failed to load' );
} )
+ .then( done, done )
.then( next, abort );
};
} );
- QUnit.stop();
- process( queue, QUnit.start );
+ process( queue );
} );
// HTML in wikitext