r110214 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110213‎ | r110214 | r110215 >
Date:16:56, 28 January 2012
Author:krinkle
Status:ok
Tags:
Comment:
Fix jquery.client.test breakage
* Remove both classes before adding one. Previously test ran normally on an "ltr" page because the loop starts with "ltr" and they matches naturally. It broke on pages that started out with "rtl". Fixed now
* Restored body classes after the test, otherwise both "rtl" and "ltr" would be gone, could influence other tests and layout stuff on the page.

* Follows-up r101845
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/jquery/jquery.client.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.client.test.js
@@ -285,19 +285,25 @@
286286 test( 'User-agent matches against WikiEditor\'s compatibility map', function() {
287287 expect( uacount * 2 ); // double since we test both LTR and RTL
288288
 289+ var $body = $( 'body' ),
 290+ bodyClasses = $body.attr( 'class' );
 291+
289292 // Loop through and run tests
290 - $.each( uas, function( agent, data ) {
291 - $.each( ['ltr', 'rtl'], function( i, dir ) {
292 - $('body').addClass(dir);
 293+ $.each( uas, function ( agent, data ) {
 294+ $.each( ['ltr', 'rtl'], function ( i, dir ) {
 295+ $body.removeClass( 'ltr rtl' ).addClass( dir );
293296 var profile = $.client.profile( {
294297 userAgent: agent,
295298 platform: data.platform
296299 } );
297300 var testMatch = $.client.test( testMap, profile );
298 - $('body').removeClass(dir);
 301+ $body.removeClass( dir );
299302
300303 equal( testMatch, data.wikiEditor[dir], 'testing comparison based on ' + dir + ', ' + agent );
301304 });
302305 });
 306+
 307+ // Restore body classes
 308+ $body.attr( 'class', bodyClasses );
303309 });
304310

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101845Add to jquery.client's qunit tests by actually testing the test() function ag...brion18:33, 3 November 2011

Status & tagging log