From: Siebrand Mazeland Date: Fri, 15 Feb 2013 11:10:19 +0000 (+0100) Subject: Update formatting X-Git-Tag: 1.31.0-rc.0~20682 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=1963fcf279ef458b0ea3b7a51da7b7606963350f;p=lhc%2Fweb%2Fwiklou.git Update formatting 9 of n. Change-Id: Ide20743a2e84ff68549286120e6cff9d9f396f54 --- diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js index b751ca929f..c89656d569 100644 --- a/tests/qunit/data/testrunner.js +++ b/tests/qunit/data/testrunner.js @@ -52,7 +52,7 @@ /** * CompletenessTest */ - // Adds toggle checkbox to header + // Adds toggle checkbox to header QUnit.config.urlConfig.push( { id: 'completenesstest', label: 'Run CompletenessTest', @@ -92,7 +92,7 @@ /** * Test environment recommended for all QUnit test modules */ - // Whether to log environment changes to the console + // Whether to log environment changes to the console QUnit.config.urlConfig.push( 'mwlogenv' ); /** @@ -118,7 +118,7 @@ } function freshMessagesCopy( custom ) { - return $.extend( /*deep=*/true, {}, liveMessages, custom ); + return $.extend( /*deep=*/true, {}, liveMessages, custom ); } log = QUnit.urlParams.mwlogenv ? mw.log : function () {}; @@ -172,7 +172,7 @@ // Whether this one fails or not, forwards it to // the 'done' (resolve) callback of the alternative promise. arg.always( alt.resolve ); - }); + } ); return $.when.apply( $, altPromises ); }; @@ -221,7 +221,7 @@ * initializations defined above in this file. */ envExecCount = 0; - QUnit.module( 'mediawiki.tests.qunit.testrunner', QUnit.newMwEnvironment({ + QUnit.module( 'mediawiki.tests.qunit.testrunner', QUnit.newMwEnvironment( { setup: function () { envExecCount += 1; this.mwHtmlLive = mw.html; @@ -240,7 +240,7 @@ messages: { testMsg: 'Foo.' } - }) ); + } ) ); QUnit.test( 'Setup', 3, function ( assert ) { assert.equal( mw.html.escape( 'foo' ), 'mocked-1', 'extra setup() callback was ran.' ); @@ -249,13 +249,13 @@ mw.config.set( 'testVar', 'bar' ); mw.messages.set( 'testMsg', 'Bar.' ); - }); + } ); QUnit.test( 'Teardown', 3, function ( assert ) { assert.equal( mw.html.escape( 'foo' ), 'mocked-2', 'extra setup() callback was re-ran.' ); assert.equal( mw.config.get( 'testVar' ), 'foo', 'config object restored and re-applied after test()' ); assert.equal( mw.messages.get( 'testMsg' ), 'Foo.', 'messages object restored and re-applied after test()' ); - }); + } ); QUnit.module( 'mediawiki.tests.qunit.testrunner-after', QUnit.newMwEnvironment() ); @@ -263,6 +263,6 @@ assert.equal( mw.html.escape( '<' ), '<', 'extra teardown() callback was ran.' ); assert.equal( mw.config.get( 'testVar' ), null, 'config object restored to live in next module()' ); assert.equal( mw.messages.get( 'testMsg' ), null, 'messages object restored to live in next module()' ); - }); + } ); }( jQuery, mediaWiki, QUnit ) ); diff --git a/tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js b/tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js index 2990de2148..c21844eb84 100644 --- a/tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js @@ -15,10 +15,12 @@ // Basic sendkey-implementation function addChars( $input, charstr ) { var c, len; + function x( $input, i ) { // Add character to the value return $input.val() + charstr.charAt( i ); } + for ( c = 0, len = charstr.length; c < len; c += 1 ) { $input .val( x( $input, c ) ) @@ -35,72 +37,72 @@ * The limit should be less than 20 (the sample data's length) */ function byteLimitTest( options ) { - var opt = $.extend({ + var opt = $.extend( { description: '', $input: null, sample: '', hasLimit: false, expected: '', limit: null - }, options); + }, options ); QUnit.asyncTest( opt.description, opt.hasLimit ? 3 : 2, function ( assert ) { - setTimeout( function () { - var rawVal, fn, effectiveVal; - - opt.$input.appendTo( '#qunit-fixture' ); - - // Simulate pressing keys for each of the sample characters - addChars( opt.$input, opt.sample ); - - rawVal = opt.$input.val(); - fn = opt.$input.data( 'byteLimit.callback' ); - effectiveVal = fn ? fn( rawVal ) : rawVal; - - if ( opt.hasLimit ) { - assert.ltOrEq( - $.byteLength( effectiveVal ), - opt.limit, - 'Prevent keypresses after byteLimit was reached, length never exceeded the limit' - ); - assert.equal( - $.byteLength( rawVal ), - $.byteLength( opt.expected ), - 'Not preventing keypresses too early, length has reached the expected length' - ); - assert.equal( rawVal, opt.expected, 'New value matches the expected string' ); - - } else { - assert.equal( - $.byteLength( effectiveVal ), - $.byteLength( opt.expected ), - 'Unlimited scenarios are not affected, expected length reached' - ); - assert.equal( rawVal, opt.expected, 'New value matches the expected string' ); - } - QUnit.start(); - }, 10 ); + setTimeout( function () { + var rawVal, fn, effectiveVal; + + opt.$input.appendTo( '#qunit-fixture' ); + + // Simulate pressing keys for each of the sample characters + addChars( opt.$input, opt.sample ); + + rawVal = opt.$input.val(); + fn = opt.$input.data( 'byteLimit.callback' ); + effectiveVal = fn ? fn( rawVal ) : rawVal; + + if ( opt.hasLimit ) { + assert.ltOrEq( + $.byteLength( effectiveVal ), + opt.limit, + 'Prevent keypresses after byteLimit was reached, length never exceeded the limit' + ); + assert.equal( + $.byteLength( rawVal ), + $.byteLength( opt.expected ), + 'Not preventing keypresses too early, length has reached the expected length' + ); + assert.equal( rawVal, opt.expected, 'New value matches the expected string' ); + + } else { + assert.equal( + $.byteLength( effectiveVal ), + $.byteLength( opt.expected ), + 'Unlimited scenarios are not affected, expected length reached' + ); + assert.equal( rawVal, opt.expected, 'New value matches the expected string' ); + } + QUnit.start(); + }, 10 ); } ); } - byteLimitTest({ + byteLimitTest( { description: 'Plain text input', $input: $( '' ), sample: simpleSample, hasLimit: false, expected: simpleSample - }); + } ); - byteLimitTest({ + byteLimitTest( { description: 'Plain text input. Calling byteLimit with no parameters and no maxlength attribute (bug 36310)', $input: $( '' ) .byteLimit(), sample: simpleSample, hasLimit: false, expected: simpleSample - }); + } ); - byteLimitTest({ + byteLimitTest( { description: 'Limit using the maxlength attribute', $input: $( '' ) .attr( 'maxlength', '10' ) @@ -109,9 +111,9 @@ hasLimit: true, limit: 10, expected: '1234567890' - }); + } ); - byteLimitTest({ + byteLimitTest( { description: 'Limit using a custom value', $input: $( '' ) .byteLimit( 10 ), @@ -119,9 +121,9 @@ hasLimit: true, limit: 10, expected: '1234567890' - }); + } ); - byteLimitTest({ + byteLimitTest( { description: 'Limit using a custom value, overriding maxlength attribute', $input: $( '' ) .attr( 'maxlength', '10' ) @@ -130,9 +132,9 @@ hasLimit: true, limit: 15, expected: '123456789012345' - }); + } ); - byteLimitTest({ + byteLimitTest( { description: 'Limit using a custom value (multibyte)', $input: $( '' ) .byteLimit( 14 ), @@ -140,9 +142,9 @@ hasLimit: true, limit: 14, expected: '1234567890' + U_20AC + '1' - }); + } ); - byteLimitTest({ + byteLimitTest( { description: 'Limit using a custom value (multibyte) overlapping a byte', $input: $( '' ) .byteLimit( 12 ), @@ -150,9 +152,9 @@ hasLimit: true, limit: 12, expected: '1234567890' + '12' - }); + } ); - byteLimitTest({ + byteLimitTest( { description: 'Pass the limit and a callback as input filter', $input: $( '' ) .byteLimit( 6, function ( val ) { @@ -168,9 +170,9 @@ hasLimit: true, limit: 6, // 'Sample' length expected: 'User:Sample' - }); + } ); - byteLimitTest({ + byteLimitTest( { description: 'Limit using the maxlength attribute and pass a callback as input filter', $input: $( '' ) .attr( 'maxlength', '6' ) @@ -187,7 +189,7 @@ hasLimit: true, limit: 6, // 'Sample' length expected: 'User:Sample' - }); + } ); QUnit.test( 'Confirm properties and attributes set', 4, function ( assert ) { var $el, $elA, $elB; @@ -230,7 +232,7 @@ assert.strictEqual( $el.length, 2, 'Verify that there are no other elements clashing with this test suite' ); $el.byteLimit(); - }); + } ); QUnit.test( 'Trim from insertion when limit exceeded', 2, function ( assert ) { var $el; @@ -252,6 +254,5 @@ .val( 'azbc' ).trigger( 'change' ); assert.strictEqual( $el.val(), 'abc', 'Trim from the insertion point (at 1), not the end' ); - }); - + } ); }( jQuery, mediaWiki ) ); diff --git a/tests/qunit/suites/resources/jquery/jquery.client.test.js b/tests/qunit/suites/resources/jquery/jquery.client.test.js index 44aaefd0bc..88bbf5c475 100644 --- a/tests/qunit/suites/resources/jquery/jquery.client.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.client.test.js @@ -278,13 +278,13 @@ }; $.each( uas, function () { uacount++; - }); + } ); return uas; }() ); QUnit.test( 'profile userAgent support', uacount, function ( assert ) { // Generate a client profile object and compare recursively - var uaTest = function( rawUserAgent, data ) { + var uaTest = function ( rawUserAgent, data ) { var ret = $.client.profile( { userAgent: rawUserAgent, platform: data.platform @@ -298,6 +298,7 @@ QUnit.test( 'profile return validation for current user agent', 7, function ( assert ) { var p = $.client.profile(); + function unknownOrType( val, type, summary ) { assert.ok( typeof val === type || val === 'unknown', summary ); } @@ -309,7 +310,7 @@ unknownOrType( p.version, 'string', 'p.version is a string (or "unknown")' ); unknownOrType( p.versionBase, 'string', 'p.versionBase is a string (or "unknown")' ); assert.equal( typeof p.versionNumber, 'number', 'p.versionNumber is a number' ); - }); + } ); // Example from WikiEditor // Make sure to use raw numbers, a string like "7.0" would fail on a @@ -346,10 +347,10 @@ assert.equal( typeof testMatch, 'boolean', 'test returns a boolean value' ); - }); + } ); QUnit.test( 'User-agent matches against WikiEditor\'s compatibility map', uacount * 2, function ( assert ) { - var $body = $( 'body' ), + var $body = $( 'body' ), bodyClasses = $body.attr( 'class' ); // Loop through and run tests @@ -365,10 +366,10 @@ $body.removeClass( dir ); assert.equal( testMatch, data.wikiEditor[dir], 'testing comparison based on ' + dir + ', ' + agent ); - }); - }); + } ); + } ); // Restore body classes $body.attr( 'class', bodyClasses ); - }); + } ); }( jQuery ) ); diff --git a/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js b/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js index 3ffcbf5741..2765498743 100644 --- a/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js @@ -2,38 +2,36 @@ QUnit.module( 'jquery.mwExtension', QUnit.newMwEnvironment() ); QUnit.test( 'String functions', function ( assert ) { - assert.equal( $.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' ); assert.equal( $.trimRight( ' foo bar ' ), ' foo bar', 'trimRight' ); assert.equal( $.ucFirst( 'foo' ), 'Foo', 'ucFirst' ); assert.equal( $.escapeRE( '