1 module( 'jquery.highlightText' );
3 test( '-- Initial check', function() {
5 ok( $.fn
.highlightText
, 'jQuery.fn.highlightText defined' );
8 test( 'Check', function() {
12 text
: 'Blue Öyster Cult',
14 expected
: '<span class="highlight">Blue</span> Öyster Cult'
18 text
: 'Blue Öyster Cult',
20 expected
: '<span class="highlight">Blue</span> Öyster Cult'
24 text
: 'Blue Öyster Cult',
26 expected
: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
30 text
: 'Blue Öyster Cult',
32 expected
: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
36 text
: 'Blue Öyster Cult',
38 expected
: '<span class="highlight">Blue</span> Öyster Cult'
42 text
: 'Blue Öyster Cult',
44 expected
: '<span class="highlight">Blue</span> Öyster Cult'
48 text
: 'Blue Öyster Cult',
50 expected
: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
54 text
: 'Blue Öyster Cult',
55 highlight
: ' Blue Öy',
56 expected
: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
59 desc
: 'Test 009: Highlighter broken on starting Umlaut?',
61 highlight
: 'Österreich',
62 expected
: '<span class="highlight">Österreich</span>'
65 desc
: 'Test 010: Highlighter broken on starting Umlaut?',
68 expected
: '<span class="highlight">Ö</span>sterreich'
71 desc
: 'Test 011: Highlighter broken on starting Umlaut?',
74 expected
: '<span class="highlight">Öst</span>erreich'
77 desc
: 'Test 012: Highlighter broken on starting Umlaut?',
80 expected
: 'Österreich'
83 desc
: 'Test 013: Highlighter broken on punctuation mark?',
84 text
: 'So good. To be there',
86 expected
: 'So <span class="highlight">good</span>. To be there'
89 desc
: 'Test 014: Highlighter broken on space?',
90 text
: 'So good. To be there',
92 expected
: 'So good. To <span class="highlight">be</span> there'
95 desc
: 'Test 015: Highlighter broken on space?',
96 text
: 'So good. To be there',
98 expected
: 'So good. To <span class="highlight">be</span> there'
101 desc
: 'Test 016: Highlighter broken on space?',
102 text
: 'So good. To be there',
104 expected
: 'So good. To <span class="highlight">be</span> there'
107 desc
: 'Test 017: Highlighter broken on space?',
108 text
: 'So good. To be there',
110 expected
: 'So good. To <span class="highlight">be</span> there'
113 desc
: 'Test 018: Highlighter broken on special character at the end?',
114 text
: 'So good. xbß',
116 expected
: 'So good. <span class="highlight">xbß</span>'
119 desc
: 'Test 019: Highlighter broken on special character at the end?',
120 text
: 'So good. xbß.',
122 expected
: 'So good. <span class="highlight">xbß.</span>'
125 desc
: 'Test 020: Hebrew',
126 text
: 'חסיד אומות העולם',
127 highlight
: 'חסיד אומות העולם',
128 expected
: '<span class="highlight">חסיד</span> <span class="highlight">אומות</span> <span class="highlight">העולם</span>'
131 desc
: 'Test 021: Hebrew',
132 text
: 'חסיד אומות העולם',
134 expected
: '<span class="highlight">חסי</span>ד אומות העולם'
137 desc
: 'Test 022: Japanese',
139 highlight
: '諸国民の中の正義の人',
140 expected
: '<span class="highlight">諸国民の中の正義の人</span>'
143 desc
: 'Test 023: Japanese',
146 expected
: '<span class="highlight">諸国</span>民の中の正義の人'
149 desc
: 'Test 024: French text and « french quotes » (guillemets)',
150 text
: "« L'oiseau est sur l’île »",
151 highlight
: "« L'oiseau est sur l’île »",
152 expected
: '<span class="highlight">«</span> <span class="highlight">L\'oiseau</span> <span class="highlight">est</span> <span class="highlight">sur</span> <span class="highlight">l’île</span> <span class="highlight">»</span>'
155 desc
: 'Test 025: French text and « french quotes » (guillemets)',
156 text
: "« L'oiseau est sur l’île »",
157 highlight
: "« L'oise",
158 expected
: '<span class="highlight">«</span> <span class="highlight">L\'oise</span>au est sur l’île »'
161 expect(cases
.length
);
164 $.each(cases
, function( i
, item
) {
165 $fixture
= $( '<p></p>' ).text( item
.text
);
166 $fixture
.highlightText( item
.highlight
);
169 $('<p>' + item
.expected
+ '</p>').html(), // re-parse to normalize!
170 item
.desc
|| undefined