From 4917e3e7f73bb4c0a03d5c7d802e65ee5db928e0 Mon Sep 17 00:00:00 2001 From: Krinkle Date: Sat, 28 Jan 2012 16:56:10 +0000 Subject: [PATCH] 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 --- .../suites/resources/jquery/jquery.client.test.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 ); }); -- 2.20.1