2 QUnit.module( 'jquery.highlightText', QUnit.newMwEnvironment() );
4 QUnit.test( 'Check', function ( assert ) {
5 var $fixture, cases = [
8 text: 'Blue Öyster Cult',
10 expected: '<span class="highlight">Blue</span> Öyster Cult'
14 text: 'Blue Öyster Cult',
16 expected: '<span class="highlight">Blue</span> Öyster Cult'
20 text: 'Blue Öyster Cult',
22 expected: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
26 text: 'Blue Öyster Cult',
28 expected: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
32 text: 'Blue Öyster Cult',
34 expected: '<span class="highlight">Blue</span> Öyster Cult'
38 text: 'Blue Öyster Cult',
40 expected: '<span class="highlight">Blue</span> Öyster Cult'
44 text: 'Blue Öyster Cult',
46 expected: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
50 text: 'Blue Öyster Cult',
51 highlight: ' Blue Öy',
52 expected: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
55 desc: 'Test 009: Highlighter broken on starting Umlaut?',
57 highlight: 'Österreich',
58 expected: '<span class="highlight">Österreich</span>'
61 desc: 'Test 010: Highlighter broken on starting Umlaut?',
64 expected: '<span class="highlight">Ö</span>sterreich'
67 desc: 'Test 011: Highlighter broken on starting Umlaut?',
70 expected: '<span class="highlight">Öst</span>erreich'
73 desc: 'Test 012: Highlighter broken on starting Umlaut?',
76 expected: 'Österreich'
79 desc: 'Test 013: Highlighter broken on punctuation mark?',
80 text: 'So good. To be there',
82 expected: 'So <span class="highlight">good</span>. To be there'
85 desc: 'Test 014: Highlighter broken on space?',
86 text: 'So good. To be there',
88 expected: 'So good. To <span class="highlight">be</span> there'
91 desc: 'Test 015: Highlighter broken on space?',
92 text: 'So good. To be there',
94 expected: 'So good. To <span class="highlight">be</span> there'
97 desc: 'Test 016: Highlighter broken on space?',
98 text: 'So good. To be there',
100 expected: 'So good. To <span class="highlight">be</span> there'
103 desc: 'Test 017: Highlighter broken on space?',
104 text: 'So good. To be there',
106 expected: 'So good. To <span class="highlight">be</span> there'
109 desc: 'Test 018: en de Highlighter broken on special character at the end?',
110 text: 'So good. xbß',
112 expected: 'So good. <span class="highlight">xbß</span>'
115 desc: 'Test 019: en de Highlighter broken on special character at the end?',
116 text: 'So good. xbß.',
118 expected: 'So good. <span class="highlight">xbß.</span>'
121 desc: 'Test 020: RTL he Hebrew',
122 text: 'חסיד אומות העולם',
123 highlight: 'חסיד אומות העולם',
124 expected: '<span class="highlight">חסיד</span> <span class="highlight">אומות</span> <span class="highlight">העולם</span>'
127 desc: 'Test 021: RTL he Hebrew',
128 text: 'חסיד אומות העולם',
130 expected: '<span class="highlight">חסי</span>ד אומות העולם'
133 desc: 'Test 022: ja Japanese',
135 highlight: '諸国民の中の正義の人',
136 expected: '<span class="highlight">諸国民の中の正義の人</span>'
139 desc: 'Test 023: ja Japanese',
142 expected: '<span class="highlight">諸国</span>民の中の正義の人'
145 desc: 'Test 024: fr French text and « french quotes » (guillemets)',
146 text: '« L\'oiseau est sur l’île »',
147 highlight: '« L\'oiseau est sur l’île »',
148 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>'
151 desc: 'Test 025: fr French text and « french quotes » (guillemets)',
152 text: '« L\'oiseau est sur l’île »',
153 highlight: '« L\'oise',
154 expected: '<span class="highlight">«</span> <span class="highlight">L\'oise</span>au est sur l’île »'
157 desc: 'Test 025a: fr French text and « french quotes » (guillemets) - does it match the single strings "«" and "L" separately?',
158 text: '« L\'oiseau est sur l’île »',
160 expected: '<span class="highlight">«</span> <span class="highlight">L</span>\'oiseau est sur <span class="highlight">l</span>’île »'
163 desc: 'Test 026: ru Russian',
164 text: 'Праведники мира',
165 highlight: 'Праведники мира',
166 expected: '<span class="highlight">Праведники</span> <span class="highlight">мира</span>'
169 desc: 'Test 027: ru Russian',
170 text: 'Праведники мира',
172 expected: '<span class="highlight">Праве</span>дники мира'
175 desc: 'Test 028 ka Georgian',
176 text: 'მთავარი გვერდი',
177 highlight: 'მთავარი გვერდი',
178 expected: '<span class="highlight">მთავარი</span> <span class="highlight">გვერდი</span>'
181 desc: 'Test 029 ka Georgian',
182 text: 'მთავარი გვერდი',
184 expected: '<span class="highlight">მთა</span>ვარი გვერდი'
187 desc: 'Test 030 hy Armenian',
188 text: 'Նոնա Գափրինդաշվիլի',
189 highlight: 'Նոնա Գափրինդաշվիլի',
190 expected: '<span class="highlight">Նոնա</span> <span class="highlight">Գափրինդաշվիլի</span>'
193 desc: 'Test 031 hy Armenian',
194 text: 'Նոնա Գափրինդաշվիլի',
196 expected: '<span class="highlight">Նոն</span>ա Գափրինդաշվիլի'
199 desc: 'Test 032: th Thai',
201 highlight: 'พอล แอร์ดิช',
202 expected: '<span class="highlight">พอล</span> <span class="highlight">แอร์ดิช</span>'
205 desc: 'Test 033: th Thai',
208 expected: '<span class="highlight">พอ</span>ล แอร์ดิช'
211 desc: 'Test 034: RTL ar Arabic',
213 highlight: 'بول إيردوس',
214 expected: '<span class="highlight">بول</span> <span class="highlight">إيردوس</span>'
217 desc: 'Test 035: RTL ar Arabic',
220 expected: '<span class="highlight">بو</span>ل إيردوس'
223 QUnit.expect( cases.length );
225 $.each( cases, function ( i, item ) {
226 $fixture = $( '<p>' ).text( item.text ).highlightText( item.highlight );
229 // Re-parse to normalize
230 $( '<p>' ).html( item.expected ).html(),
231 item.desc || undefined