Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.highlightText.test.js |
— | — | @@ -6,32 +6,34 @@ |
7 | 7 | } ); |
8 | 8 | |
9 | 9 | test( 'Check', function() { |
10 | | - expect(2); |
| 10 | + var cases = [ |
| 11 | + { |
| 12 | + text: 'Blue Öyster Cult', |
| 13 | + highlight: 'Blue', |
| 14 | + expected: '<span class="highlight">Blue</span> Öyster Cult' |
| 15 | + }, |
| 16 | + { |
| 17 | + text: 'Österreich', |
| 18 | + highlight: 'Österreich', |
| 19 | + expected: '<span class="highlight">Österreich</span>' |
| 20 | + }, |
| 21 | + { |
| 22 | + desc: 'Highlighter broken on punctuation mark', |
| 23 | + text: 'So good. To be there', |
| 24 | + highlight: 'good', |
| 25 | + expected: 'So <span class="highlight">good</span>. To be there' |
| 26 | + } |
| 27 | + ]; |
| 28 | + expect(cases.length); |
11 | 29 | var $fixture; |
12 | 30 | |
13 | | - $fixture = $( '<p>Blue Öyster Cult</p>' ); |
14 | | - $fixture.highlightText( 'Blue' ); |
15 | | - equal( |
16 | | - '<span class="highlight">Blue</span> Öyster Cult', |
17 | | - $fixture.html() |
18 | | - ); |
19 | | - |
20 | | - $fixture = $( '<p>Österreich</p>' ); |
21 | | - $fixture.highlightText( 'Österreich' ); |
22 | | - equal( |
23 | | - '<span class="highlight">Österreich</span>', |
24 | | - $fixture.html() |
25 | | - ); |
26 | | - |
27 | | - /** |
28 | | - * Highlighter broken on punctuation mark. |
29 | | - */ |
30 | | - /** dont forget to update the value in expect() at the top! |
31 | | - $fixture = $( '<p>So good. To be there</p>' ); |
32 | | - $fixture.highlightText( 'good' ); |
33 | | - equal( |
34 | | - 'So <span class="highlight">good</span>. To be there', |
35 | | - $fixture.html() |
36 | | - ); |
37 | | - */ |
| 31 | + $.each(cases, function( i, item ) { |
| 32 | + $fixture = $( '<p></p>' ).text( item.text ); |
| 33 | + $fixture.highlightText( item.highlight ); |
| 34 | + equals( |
| 35 | + $fixture.html(), |
| 36 | + $('<p>' + item.expected + '</p>').html(), // re-parse to normalize! |
| 37 | + item.desc || undefined |
| 38 | + ); |
| 39 | + } ); |
38 | 40 | } ); |