Followup r94609: fix jquery.highlightText test cases on IE, simplify test case setup...
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.highlightText.test.js
1 module( 'jquery.highlightText' );
2
3 test( '-- Initial check', function() {
4 expect(1);
5 ok( $.fn.highlightText, 'jQuery.fn.highlightText defined' );
6 } );
7
8 test( 'Check', function() {
9 var cases = [
10 {
11 text: 'Blue Öyster Cult',
12 highlight: 'Blue',
13 expected: '<span class="highlight">Blue</span> Öyster Cult'
14 },
15 {
16 text: 'Österreich',
17 highlight: 'Österreich',
18 expected: '<span class="highlight">Österreich</span>'
19 },
20 {
21 desc: 'Highlighter broken on punctuation mark',
22 text: 'So good. To be there',
23 highlight: 'good',
24 expected: 'So <span class="highlight">good</span>. To be there'
25 }
26 ];
27 expect(cases.length);
28 var $fixture;
29
30 $.each(cases, function( i, item ) {
31 $fixture = $( '<p></p>' ).text( item.text );
32 $fixture.highlightText( item.highlight );
33 equals(
34 $fixture.html(),
35 $('<p>' + item.expected + '</p>').html(), // re-parse to normalize!
36 item.desc || undefined
37 );
38 } );
39 } );