Debian Codegraph @

tests/qunit/resources/jquery.highlightText.test.js

raw symbols SCIP
1 QUnit.module( 'jquery.highlightText', () => {
2
3 QUnit.test.each( 'highlightText()', [
4 {
5 text: 'Blue Öyster Cult',
6 highlight: 'Blue',
7 expected: '<span class="highlight">Blue</span> Öyster Cult'
8 },
9 {
10 text: 'Blue Öyster Cult',
11 highlight: 'Blue ',
12 expected: '<span class="highlight">Blue</span> Öyster Cult'
13 },
14 {
15 text: 'Blue Öyster Cult',
16 highlight: 'Blue Ö',
17 expected: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
18 },
19 {
20 text: 'Blue Öyster Cult',
21 highlight: 'Blue Öy',
22 expected: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
23 },
24 {
25 text: 'Blue Öyster Cult',
26 highlight: ' Blue',
27 expected: '<span class="highlight">Blue</span> Öyster Cult'
28 },
29 {
30 text: 'Blue Öyster Cult',
31 highlight: ' Blue ',
32 expected: '<span class="highlight">Blue</span> Öyster Cult'
33 },
34 {
35 text: 'Blue Öyster Cult',
36 highlight: ' Blue Ö',
37 expected: '<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster Cult'
38 },
39 {
40 text: 'Blue Öyster Cult',
41 highlight: ' Blue Öy',
42 expected: '<span class="highlight">Blue</span> <span class="highlight">Öy</span>ster Cult'
43 },
44 // Highlighter on starting Umlaut
45 {
46 text: 'Österreich',
47 highlight: 'Österreich',
48 expected: '<span class="highlight">Österreich</span>'
49 },
50 {
51 text: 'Österreich',
52 highlight: 'Ö',
53 expected: '<span class="highlight">Ö</span>sterreich'
54 },
55 {
56 text: 'Österreich',
57 highlight: 'Öst',
58 expected: '<span class="highlight">Öst</span>erreich'
59 },
60 {
61 text: 'Österreich',
62 highlight: 'Oe',
63 expected: 'Österreich'
64 },
65 {
66 text: 'So good. To be there',
67 highlight: 'good',
68 expected: 'So <span class="highlight">good</span>. To be there'
69 },
70 // Highlighter on space
71 {
72 text: 'So good. To be there',
73 highlight: 'be',
74 expected: 'So good. To <span class="highlight">be</span> there'
75 },
76 {
77 text: 'So good. To be there',
78 highlight: ' be',
79 expected: 'So good. To <span class="highlight">be</span> there'
80 },
81 {
82 text: 'So good. To be there',
83 highlight: 'be ',
84 expected: 'So good. To <span class="highlight">be</span> there'
85 },
86 {
87 text: 'So good. To be there',
88 highlight: ' be ',
89 expected: 'So good. To <span class="highlight">be</span> there'
90 },
91 // Highlighter with special character at the end
92 {
93 text: 'So good. xbß',
94 highlight: 'xbß',
95 expected: 'So good. <span class="highlight">xbß</span>'
96 },
97 {
98 text: 'So good. xbß.',
99 highlight: 'xbß.',
100 expected: 'So good. <span class="highlight">xbß.</span>'
101 },
102 {
103 text: 'חסיד אומות העולם',
104 highlight: 'חסיד אומות העולם',
105 expected: '<span class="highlight">חסיד</span> <span class="highlight">אומות</span> <span class="highlight">העולם</span>'
106 },
107 {
108 text: 'חסיד אומות העולם',
109 highlight: 'חסי',
110 expected: '<span class="highlight">חסי</span>ד אומות העולם'
111 },
112 // Japanese (ja)
113 {
114 text: '諸国民の中の正義の人',
115 highlight: '諸国民の中の正義の人',
116 expected: '<span class="highlight">諸国民の中の正義の人</span>'
117 },
118 {
119 text: '諸国民の中の正義の人',
120 highlight: '諸国',
121 expected: '<span class="highlight">諸国</span>民の中の正義の人'
122 },
123 // French (fr) text and french guillemets quotes
124 {
125 text: '« L\'oiseau est sur l’île »',
126 highlight: '« L\'oiseau est sur l’île »',
127 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>'
128 },
129 {
130 text: '« L\'oiseau est sur l’île »',
131 highlight: '« L\'oise',
132 expected: '<span class="highlight">«</span> <span class="highlight">L\'oise</span>au est sur l’île »'
133 },
134 {
135 // does it match the single strings "«" and "L" separately?
136 text: '« L\'oiseau est sur l’île »',
137 highlight: '« L',
138 expected: '<span class="highlight">«</span> <span class="highlight">L</span>\'oiseau est sur <span class="highlight">l</span>’île »'
139 },
140 // Russian (ru)
141 {
142 text: 'Праведники мира',
143 highlight: 'Праведники мира',
144 expected: '<span class="highlight">Праведники</span> <span class="highlight">мира</span>'
145 },
146 {
147 text: 'Праведники мира',
148 highlight: 'Праве',
149 expected: '<span class="highlight">Праве</span>дники мира'
150 },
151 // Georgian (ka)
152 {
153 text: 'მთავარი გვერდი',
154 highlight: 'მთავარი გვერდი',
155 expected: '<span class="highlight">მთავარი</span> <span class="highlight">გვერდი</span>'
156 },
157 {
158 text: 'მთავარი გვერდი',
159 highlight: 'მთა',
160 expected: '<span class="highlight">მთა</span>ვარი გვერდი'
161 },
162 // Armenian (hy)
163 {
164 text: 'Նոնա Գափրինդաշվիլի',
165 highlight: 'Նոնա Գափրինդաշվիլի',
166 expected: '<span class="highlight">Նոնա</span> <span class="highlight">Գափրինդաշվիլի</span>'
167 },
168 {
169 text: 'Նոնա Գափրինդաշվիլի',
170 highlight: 'Նոն',
171 expected: '<span class="highlight">Նոն</span>ա Գափրինդաշվիլի'
172 },
173 // Thai (th)
174 {
175 text: 'พอล แอร์ดิช',
176 highlight: 'พอล แอร์ดิช',
177 expected: '<span class="highlight">พอล</span> <span class="highlight">แอร์ดิช</span>'
178 },
179 {
180 text: 'พอล แอร์ดิช',
181 highlight: 'พอ',
182 expected: '<span class="highlight">พอ</span>ล แอร์ดิช'
183 },
184 // RTL: Arabic (ar)
185 {
186 text: 'بول إيردوس',
187 highlight: 'بول إيردوس',
188 expected: '<span class="highlight">بول</span> <span class="highlight">إيردوس</span>'
189 },
190 {
191 text: 'بول إيردوس',
192 highlight: 'بو',
193 expected: '<span class="highlight">بو</span>ل إيردوس'
194 }
195 ], ( assert, item ) => {
196 const $fixture = $( '<p>' ).text( item.text ).highlightText( item.highlight );
197 assert.strictEqual(
198 $fixture.html(),
199 // Re-parse to normalize
200 $( '<p>' ).html( item.expected ).html()
201 );
202 } );
203 } );