Merge "selenium: invoke jobs to enforce eventual consistency"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.highlightText.test.js
1 ( function () {
2 QUnit.module( 'jquery.highlightText', QUnit.newMwEnvironment() );
3
4 QUnit.test( 'Check', function ( assert ) {
5 var $fixture,
6 cases = [
7 {
8 desc: 'Test 001',
9 text: 'Blue Öyster Cult',
10 highlight: 'Blue',
11 expected: '<span class="highlight">Blue</span> Öyster Cult'
12 },
13 {
14 desc: 'Test 002',
15 text: 'Blue Öyster Cult',
16 highlight: 'Blue ',
17 expected: '<span class="highlight">Blue</span> Öyster Cult'
18 },
19 {
20 desc: 'Test 003',
21 text: 'Blue Öyster Cult',
22 highlight: 'Blue Ö',
23 expected: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
24 },
25 {
26 desc: 'Test 004',
27 text: 'Blue Öyster Cult',
28 highlight: 'Blue Öy',
29 expected: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
30 },
31 {
32 desc: 'Test 005',
33 text: 'Blue Öyster Cult',
34 highlight: ' Blue',
35 expected: '<span class="highlight">Blue</span> Öyster Cult'
36 },
37 {
38 desc: 'Test 006',
39 text: 'Blue Öyster Cult',
40 highlight: ' Blue ',
41 expected: '<span class="highlight">Blue</span> Öyster Cult'
42 },
43 {
44 desc: 'Test 007',
45 text: 'Blue Öyster Cult',
46 highlight: ' Blue Ö',
47 expected: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
48 },
49 {
50 desc: 'Test 008',
51 text: 'Blue Öyster Cult',
52 highlight: ' Blue Öy',
53 expected: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
54 },
55 {
56 desc: 'Test 009: Highlighter broken on starting Umlaut?',
57 text: 'Österreich',
58 highlight: 'Österreich',
59 expected: '<span class="highlight">Österreich</span>'
60 },
61 {
62 desc: 'Test 010: Highlighter broken on starting Umlaut?',
63 text: 'Österreich',
64 highlight: 'Ö',
65 expected: '<span class="highlight">Ö</span>sterreich'
66 },
67 {
68 desc: 'Test 011: Highlighter broken on starting Umlaut?',
69 text: 'Österreich',
70 highlight: 'Öst',
71 expected: '<span class="highlight">Öst</span>erreich'
72 },
73 {
74 desc: 'Test 012: Highlighter broken on starting Umlaut?',
75 text: 'Österreich',
76 highlight: 'Oe',
77 expected: 'Österreich'
78 },
79 {
80 desc: 'Test 013: Highlighter broken on punctuation mark?',
81 text: 'So good. To be there',
82 highlight: 'good',
83 expected: 'So <span class="highlight">good</span>. To be there'
84 },
85 {
86 desc: 'Test 014: Highlighter broken on space?',
87 text: 'So good. To be there',
88 highlight: 'be',
89 expected: 'So good. To <span class="highlight">be</span> there'
90 },
91 {
92 desc: 'Test 015: Highlighter broken on space?',
93 text: 'So good. To be there',
94 highlight: ' be',
95 expected: 'So good. To <span class="highlight">be</span> there'
96 },
97 {
98 desc: 'Test 016: Highlighter broken on space?',
99 text: 'So good. To be there',
100 highlight: 'be ',
101 expected: 'So good. To <span class="highlight">be</span> there'
102 },
103 {
104 desc: 'Test 017: Highlighter broken on space?',
105 text: 'So good. To be there',
106 highlight: ' be ',
107 expected: 'So good. To <span class="highlight">be</span> there'
108 },
109 {
110 desc: 'Test 018: en de Highlighter broken on special character at the end?',
111 text: 'So good. xbß',
112 highlight: 'xbß',
113 expected: 'So good. <span class="highlight">xbß</span>'
114 },
115 {
116 desc: 'Test 019: en de Highlighter broken on special character at the end?',
117 text: 'So good. xbß.',
118 highlight: 'xbß.',
119 expected: 'So good. <span class="highlight">xbß.</span>'
120 },
121 {
122 desc: 'Test 020: RTL he Hebrew',
123 text: 'חסיד אומות העולם',
124 highlight: 'חסיד אומות העולם',
125 expected: '<span class="highlight">חסיד</span> <span class="highlight">אומות</span> <span class="highlight">העולם</span>'
126 },
127 {
128 desc: 'Test 021: RTL he Hebrew',
129 text: 'חסיד אומות העולם',
130 highlight: 'חסי',
131 expected: '<span class="highlight">חסי</span>ד אומות העולם'
132 },
133 {
134 desc: 'Test 022: ja Japanese',
135 text: '諸国民の中の正義の人',
136 highlight: '諸国民の中の正義の人',
137 expected: '<span class="highlight">諸国民の中の正義の人</span>'
138 },
139 {
140 desc: 'Test 023: ja Japanese',
141 text: '諸国民の中の正義の人',
142 highlight: '諸国',
143 expected: '<span class="highlight">諸国</span>民の中の正義の人'
144 },
145 {
146 desc: 'Test 024: fr French text and « french quotes » (guillemets)',
147 text: '« L\'oiseau est sur l’île »',
148 highlight: '« L\'oiseau est sur l’île »',
149 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>'
150 },
151 {
152 desc: 'Test 025: fr French text and « french quotes » (guillemets)',
153 text: '« L\'oiseau est sur l’île »',
154 highlight: '« L\'oise',
155 expected: '<span class="highlight">«</span> <span class="highlight">L\'oise</span>au est sur l’île »'
156 },
157 {
158 desc: 'Test 025a: fr French text and « french quotes » (guillemets) - does it match the single strings "«" and "L" separately?',
159 text: '« L\'oiseau est sur l’île »',
160 highlight: '« L',
161 expected: '<span class="highlight">«</span> <span class="highlight">L</span>\'oiseau est sur <span class="highlight">l</span>’île »'
162 },
163 {
164 desc: 'Test 026: ru Russian',
165 text: 'Праведники мира',
166 highlight: 'Праведники мира',
167 expected: '<span class="highlight">Праведники</span> <span class="highlight">мира</span>'
168 },
169 {
170 desc: 'Test 027: ru Russian',
171 text: 'Праведники мира',
172 highlight: 'Праве',
173 expected: '<span class="highlight">Праве</span>дники мира'
174 },
175 {
176 desc: 'Test 028 ka Georgian',
177 text: 'მთავარი გვერდი',
178 highlight: 'მთავარი გვერდი',
179 expected: '<span class="highlight">მთავარი</span> <span class="highlight">გვერდი</span>'
180 },
181 {
182 desc: 'Test 029 ka Georgian',
183 text: 'მთავარი გვერდი',
184 highlight: 'მთა',
185 expected: '<span class="highlight">მთა</span>ვარი გვერდი'
186 },
187 {
188 desc: 'Test 030 hy Armenian',
189 text: 'Նոնա Գափրինդաշվիլի',
190 highlight: 'Նոնա Գափրինդաշվիլի',
191 expected: '<span class="highlight">Նոնա</span> <span class="highlight">Գափրինդաշվիլի</span>'
192 },
193 {
194 desc: 'Test 031 hy Armenian',
195 text: 'Նոնա Գափրինդաշվիլի',
196 highlight: 'Նոն',
197 expected: '<span class="highlight">Նոն</span>ա Գափրինդաշվիլի'
198 },
199 {
200 desc: 'Test 032: th Thai',
201 text: 'พอล แอร์ดิช',
202 highlight: 'พอล แอร์ดิช',
203 expected: '<span class="highlight">พอล</span> <span class="highlight">แอร์ดิช</span>'
204 },
205 {
206 desc: 'Test 033: th Thai',
207 text: 'พอล แอร์ดิช',
208 highlight: 'พอ',
209 expected: '<span class="highlight">พอ</span>ล แอร์ดิช'
210 },
211 {
212 desc: 'Test 034: RTL ar Arabic',
213 text: 'بول إيردوس',
214 highlight: 'بول إيردوس',
215 expected: '<span class="highlight">بول</span> <span class="highlight">إيردوس</span>'
216 },
217 {
218 desc: 'Test 035: RTL ar Arabic',
219 text: 'بول إيردوس',
220 highlight: 'بو',
221 expected: '<span class="highlight">بو</span>ل إيردوس'
222 }
223 ];
224
225 cases.forEach( function ( item ) {
226 $fixture = $( '<p>' ).text( item.text ).highlightText( item.highlight );
227 assert.strictEqual(
228 $fixture.html(),
229 // Re-parse to normalize
230 $( '<p>' ).html( item.expected ).html(),
231 item.desc || undefined
232 );
233 } );
234 } );
235 }() );