From: Krinkle Date: Sat, 28 Jan 2012 16:56:10 +0000 (+0000) Subject: Fix jquery.client.test breakage X-Git-Tag: 1.31.0-rc.0~25038 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=4917e3e7f73bb4c0a03d5c7d802e65ee5db928e0;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/tests/qunit/suites/resources/jquery/jquery.client.test.js b/tests/qunit/suites/resources/jquery/jquery.client.test.js index f6eb700e04..7be41971b5 100644 --- a/tests/qunit/suites/resources/jquery/jquery.client.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.client.test.js @@ -285,19 +285,25 @@ test( 'test', function() { test( 'User-agent matches against WikiEditor\'s compatibility map', function() { expect( uacount * 2 ); // double since we test both LTR and RTL + var $body = $( 'body' ), + bodyClasses = $body.attr( 'class' ); + // Loop through and run tests - $.each( uas, function( agent, data ) { - $.each( ['ltr', 'rtl'], function( i, dir ) { - $('body').addClass(dir); + $.each( uas, function ( agent, data ) { + $.each( ['ltr', 'rtl'], function ( i, dir ) { + $body.removeClass( 'ltr rtl' ).addClass( dir ); var profile = $.client.profile( { userAgent: agent, platform: data.platform } ); var testMatch = $.client.test( testMap, profile ); - $('body').removeClass(dir); + $body.removeClass( dir ); equal( testMatch, data.wikiEditor[dir], 'testing comparison based on ' + dir + ', ' + agent ); }); }); + + // Restore body classes + $body.attr( 'class', bodyClasses ); });