r87684 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87683‎ | r87684 | r87685 >
Date:13:22, 8 May 2011
Author:krinkle
Status:deferred (Comments)
Tags:
Comment:
mw.util.test update
* Remove isMainPage() from test suite (r87360 r87586)
* Use mw.config for wgVars (follow-up r80792 CR)
* Rename skinLinksText variable to skinLinksHtml
* Wrap lines
* removing !important from addCSS test, instead using the same selector as the original background-color declaration and letting it cascade.
* Adding css('background-color') test to verify.
Modified paths:
  • /trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js
@@ -52,7 +52,11 @@
5353 }
5454 var escapedtitle = mw.html.escape( title ).replace( / /g, '  ' );
5555 this.addedTests.push( [ 'HEADER', escapedtitle, mw.test.numberOfHeader++ ] );
56 - this.$table.append( '<tr class="mw-mwutiltest-head" id="mw-mwutiltest-head'+mw.test.numberOfHeader+'"><th colspan="4">' + escapedtitle + '</th></tr>' );
 56+ this.$table.append(
 57+ '<tr class="mw-mwutiltest-head" id="mw-mwutiltest-head'
 58+ + mw.test.numberOfHeader + '"><th colspan="4">'
 59+ + escapedtitle + '</th></tr>'
 60+ );
5761 return true;
5862 },
5963
@@ -69,27 +73,35 @@
7074 // Build page
7175 document.title = 'mediaWiki JavaScript library test suite - ' + mw.config.get( 'wgSiteName' );
7276 $( '#firstHeading' ).text( 'mediaWiki JavaScript library test suite' );
73 - var skinLinksText = 'Test in: ',
 77+ var skinLinksHtml = 'Test in: ',
7478 skinLinks = [],
7579 availableSkins = mw.config.get( 'wgAvailableSkins' ),
7680 skincode = '';
7781 for ( skincode in availableSkins ) {
78 - skinLinks.push( mw.html.element( 'a', {
79 - 'href': mw.util.wikiGetlink( wgPageName ) + '?action=mwutiltest&debug=true&useskin=' + encodeURIComponent( skincode )
80 - }, availableSkins[skincode] ) );
 82+ skinLinks.push(
 83+ mw.html.element(
 84+ 'a', {
 85+ 'href': mw.util.wikiGetlink( mw.config.get( 'wgPageName' ) )
 86+ + '?action=mwutiltest&debug=true&useskin=' + encodeURIComponent( skincode )
 87+ },
 88+ availableSkins[skincode]
 89+ )
 90+ );
8191 }
82 - skinLinksText += skinLinks.join( ' | ' ) + '.';
 92+ skinLinksHtml += skinLinks.join( ' | ' ) + '.';
8393 mw.util.$content.html(
8494 '<p>Below is a list of tests to confirm proper functionality of the mediaWiki JavaScript library</p>'
85 - + '<p>' + skinLinksText + '</p>'
 95+ + '<p>' + skinLinksHtml + '</p>'
8696 + '<hr />'
87 - + '<table id="mw-mwutiltest-table" class="wikitable" style="white-space:break; font-family:monospace,\'Courier New\'; width:100%;">'
 97+ + '<table id="mw-mwutiltest-table" class="wikitable"'
 98+ + ' style="white-space:break; font-family:monospace,\'Courier New\'; width:100%;">'
8899 + '<tr><th>Exec</th><th>Should return</th><th>Does return</th><th>Equal ?</th></tr>'
89100 + '</table>'
90101 );
91102
92103 mw.util.addCSS(
93 - '#mw-mwutiltest-table tr td { padding:0 !important; }' // Override wikitable padding for <td>
 104+ // Override wikitable padding for <td>
 105+ '#mw-mwutiltest-table tr td { padding:0 !important; }'
94106 );
95107
96108 mw.test.$table = $( 'table#mw-mwutiltest-table' );
@@ -269,10 +281,12 @@
270282 mw.test.addTest( 'typeof mw.util.addCSS',
271283 'function (string)' );
272284
273 - mw.test.addTest( 'var a = mw.util.addCSS( "#mw-js-message { background-color: #AFA !important; }" ); a.disabled;',
274 - 'false (boolean)',
275 - '(boolean)' );
 285+ mw.test.addTest( 'var a = mw.util.addCSS( "div#mw-js-message { background-color: rgb(170,255,170); }" ); a.disabled',
 286+ 'false (boolean)' );
276287
 288+ mw.test.addTest( 'jQuery( "#mw-js-message " ).css( "background-color" )',
 289+ 'rgb(170, 255, 170) (string)' );
 290+
277291 mw.test.addTest( 'typeof mw.util.toggleToc',
278292 'function (string)' );
279293
@@ -303,9 +317,6 @@
304318 mw.test.addTest( 'mw.util.$content.size()',
305319 '1 (number)' );
306320
307 - mw.test.addTest( 'mw.util.isMainPage()',
308 - 'false (boolean)' );
309 -
310321 mw.test.addTest( 'typeof mw.util.addPortletLink',
311322 'function (string)' );
312323
@@ -447,20 +458,22 @@
448459 }
449460 doesReturn = doesReturn + ' (' + typeof doesReturn + ')';
450461 var $thisrow = $testrows.eq( i - numberOfHeaders ); // since headers are rows as well
451 - $thisrow.find( '> td' ).eq(2).html( mw.html.escape( doesReturn ).replace(/ /g, '&nbsp;&nbsp;' ) );
 462+ $thisrow.find( '> td' )
 463+ .eq(2)
 464+ .html( mw.html.escape( doesReturn ).replace(/ /g, '&nbsp;&nbsp;' ) );
452465
453466 if ( doesReturn.indexOf( shouldcontain ) !== -1 ) {
454467 if ( doesReturn == shouldreturn ) {
455 - $thisrow.find( '> td' ).eq(3).css( 'background', '#AFA' ).text( 'OK' );
 468+ $thisrow.find( '>td' ).eq(3).css( 'background', '#AFA' ).text( 'OK' );
456469 numberOfPasseds++;
457470 headNumberOfPasseds++;
458471 } else {
459 - $thisrow.find( '> td' ).eq(3).css( 'background', '#FFA' ).html( '<small>PARTIALLY</small>' );
 472+ $thisrow.find( '>td' ).eq(3).css( 'background', '#FFA' ).html( '<small>PARTIALLY</small>' );
460473 numberOfPartials++;
461474 headNumberOfPartials++;
462475 }
463476 } else {
464 - $thisrow.css( 'background', '#FAA' ).find( '> td' ).eq(3).text( 'ERROR' );
 477+ $thisrow.css( 'background', '#FAA' ).find( '>td' ).eq(3).text( 'ERROR' );
465478 numberOfErrors++;
466479 headNumberOfErrors++;
467480 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80792adding links to other skins in mediaWiki JS test suite. (Previously making su...krinkle02:37, 23 January 2011
r87360mw.util.test fixes...krinkle21:57, 3 May 2011
r87586mw.util.isMainPage(); Was never released, removing before release since it's ...krinkle21:55, 6 May 2011

Comments

#Comment by Krinkle (talk | contribs)   01:28, 3 June 2011

Note that mediawiki.util.test.js was deleted in favour of the new QUnit testing framework in /tests/qunit. Any changes to it are redundant now.

Status & tagging log