From ff1bb7f22182f42570e7716e05a3f8c8391ae404 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 16 Aug 2011 19:34:47 +0000 Subject: [PATCH] Followup r94609: fix jquery.highlightText test cases on IE, simplify test case setup so new ones can be added more trivially, uncommented the failing test case. These tests were failing on IE 6, 7, and 8 because the innerHTML rendering of the highlighted text came out in caps and without quotes, such that the string didn't match the provided one. By re-normalizing the expected HTML form this check now works on those browsers. Switching common code to a loop and an array makes it easier to add new test cases: less duplication of code, and no need to manually update the number of test cases. Note that the third test case was previously commented out, but looks like a serious regression. No longer commented out, so this will fail! --- .../jquery/jquery.highlightText.test.js | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/tests/qunit/suites/resources/jquery/jquery.highlightText.test.js b/tests/qunit/suites/resources/jquery/jquery.highlightText.test.js index ba8b763cdf..6eacad0f14 100644 --- a/tests/qunit/suites/resources/jquery/jquery.highlightText.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.highlightText.test.js @@ -6,32 +6,34 @@ test( '-- Initial check', function() { } ); test( 'Check', function() { - expect(2); + var cases = [ + { + text: 'Blue Öyster Cult', + highlight: 'Blue', + expected: 'Blue Öyster Cult' + }, + { + text: 'Österreich', + highlight: 'Österreich', + expected: 'Österreich' + }, + { + desc: 'Highlighter broken on punctuation mark', + text: 'So good. To be there', + highlight: 'good', + expected: 'So good. To be there' + } + ]; + expect(cases.length); var $fixture; - $fixture = $( '

Blue Öyster Cult

' ); - $fixture.highlightText( 'Blue' ); - equal( - 'Blue Öyster Cult', - $fixture.html() - ); - - $fixture = $( '

Österreich

' ); - $fixture.highlightText( 'Österreich' ); - equal( - 'Österreich', - $fixture.html() - ); - - /** - * Highlighter broken on punctuation mark. - */ - /** dont forget to update the value in expect() at the top! - $fixture = $( '

So good. To be there

' ); - $fixture.highlightText( 'good' ); - equal( - 'So good. To be there', - $fixture.html() - ); - */ + $.each(cases, function( i, item ) { + $fixture = $( '

' ).text( item.text ); + $fixture.highlightText( item.highlight ); + equals( + $fixture.html(), + $('

' + item.expected + '

').html(), // re-parse to normalize! + item.desc || undefined + ); + } ); } ); -- 2.20.1