(bug 37755) Set robot meta tags for 'view source' pages
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.language.test.js
1 QUnit.module( 'mediawiki.language', QUnit.newMwEnvironment({
2 setup: function () {
3 this.liveLangData = mw.language.data.values;
4 mw.language.data.values = $.extend( true, {}, this.liveLangData );
5 },
6 teardown: function () {
7 // Restore
8 mw.language.data.values = this.liveLangData;
9 }
10 }) );
11
12 QUnit.test( 'mw.language getData and setData', function ( assert ) {
13 QUnit.expect( 2 );
14
15 mw.language.setData( 'en', 'testkey', 'testvalue' );
16 assert.equal( mw.language.getData( 'en', 'testkey' ), 'testvalue', 'Getter setter test for mw.language' );
17 assert.equal( mw.language.getData( 'en', 'invalidkey' ), undefined, 'Getter setter test for mw.language with invalid key' );
18 } );
19
20 function grammarTest( langCode, test ) {
21 // The test works only if the content language is opt.language
22 // because it requires [lang].js to be loaded.
23 QUnit.test( 'Grammar test for lang=' + langCode, function ( assert ) {
24 QUnit.expect( test.length );
25
26 for ( var i = 0 ; i < test.length; i++ ) {
27 assert.equal(
28 mw.language.convertGrammar( test[i].word, test[i].grammarForm ),
29 test[i].expected,
30 test[i].description
31 );
32 }
33 });
34 }
35
36 var grammarTests = {
37 bs: [
38 {
39 word: 'word',
40 grammarForm: 'instrumental',
41 expected: 's word',
42 description: 'Grammar test for instrumental case'
43 },
44 {
45 word: 'word',
46 grammarForm: 'lokativ',
47 expected: 'o word',
48 description: 'Grammar test for lokativ case'
49 }
50 ],
51
52 he: [
53 {
54 word: "ויקיפדיה",
55 grammarForm: 'prefixed',
56 expected: "וויקיפדיה",
57 description: 'Duplicate the "Waw" if prefixed'
58 },
59 {
60 word: "וולפגנג",
61 grammarForm: 'prefixed',
62 expected: "וולפגנג",
63 description: 'Duplicate the "Waw" if prefixed, but not if it is already duplicated.'
64 },
65 {
66 word: "הקובץ",
67 grammarForm: 'prefixed',
68 expected: "קובץ",
69 description: 'Remove the "He" if prefixed'
70 },
71 {
72 word: 'Wikipedia',
73 grammarForm: 'תחילית',
74 expected: '־Wikipedia',
75 description: 'GAdd a hyphen (maqaf) before non-Hebrew letters'
76 },
77 {
78 word: '1995',
79 grammarForm: 'תחילית',
80 expected: '־1995',
81 description: 'Add a hyphen (maqaf) before numbers'
82 }
83 ],
84
85 hsb: [
86 {
87 word: 'word',
88 grammarForm: 'instrumental',
89 expected: 'z word',
90 description: 'Grammar test for instrumental case'
91 },
92 {
93 word: 'word',
94 grammarForm: 'lokatiw',
95 expected: 'wo word',
96 description: 'Grammar test for lokatiw case'
97 }
98 ],
99
100 dsb: [
101 {
102 word: 'word',
103 grammarForm: 'instrumental',
104 expected: 'z word',
105 description: 'Grammar test for instrumental case'
106 },
107 {
108 word: 'word',
109 grammarForm: 'lokatiw',
110 expected: 'wo word',
111 description: 'Grammar test for lokatiw case'
112 }
113 ],
114
115 hy: [
116 {
117 word: 'Մաունա',
118 grammarForm: 'genitive',
119 expected: 'Մաունայի',
120 description: 'Grammar test for genitive case'
121 },
122 {
123 word: 'հետո',
124 grammarForm: 'genitive',
125 expected: 'հետոյի',
126 description: 'Grammar test for genitive case'
127 },
128 {
129 word: 'գիրք',
130 grammarForm: 'genitive',
131 expected: 'գրքի',
132 description: 'Grammar test for genitive case'
133 },
134 {
135 word: 'ժամանակի',
136 grammarForm: 'genitive',
137 expected: 'ժամանակիի',
138 description: 'Grammar test for genitive case'
139 }
140 ],
141
142 fi: [
143 {
144 word: 'talo',
145 grammarForm: 'genitive',
146 expected: 'talon',
147 description: 'Grammar test for genitive case'
148 },
149 {
150 word: 'linux',
151 grammarForm: 'genitive',
152 expected: 'linuxin',
153 description: 'Grammar test for genitive case'
154 },
155 {
156 word: 'talo',
157 grammarForm: 'elative',
158 expected: 'talosta',
159 description: 'Grammar test for elative case'
160 },
161 {
162 word: 'pastöroitu',
163 grammarForm: 'partitive',
164 expected: 'pastöroitua',
165 description: 'Grammar test for partitive case'
166 },
167 {
168 word: 'talo',
169 grammarForm: 'partitive',
170 expected: 'taloa',
171 description: 'Grammar test for partitive case'
172 },
173 {
174 word: 'talo',
175 grammarForm: 'illative',
176 expected: 'taloon',
177 description: 'Grammar test for illative case'
178 },
179 {
180 word: 'linux',
181 grammarForm: 'inessive',
182 expected: 'linuxissa',
183 description: 'Grammar test for inessive case'
184 }
185 ],
186
187 ru: [
188 {
189 word: 'тесть',
190 grammarForm: 'genitive',
191 expected: 'тестя',
192 description: 'Grammar test for genitive case'
193 },
194 {
195 word: 'привилегия',
196 grammarForm: 'genitive',
197 expected: 'привилегии',
198 description: 'Grammar test for genitive case'
199 },
200 {
201 word: 'установка',
202 grammarForm: 'genitive',
203 expected: 'установки',
204 description: 'Grammar test for genitive case'
205 },
206 {
207 word: 'похоти',
208 grammarForm: 'genitive',
209 expected: 'похотей',
210 description: 'Grammar test for genitive case'
211 },
212 {
213 word: 'доводы',
214 grammarForm: 'genitive',
215 expected: 'доводов',
216 description: 'Grammar test for genitive case'
217 },
218 {
219 word: 'песчаник',
220 grammarForm: 'genitive',
221 expected: 'песчаника',
222 description: 'Grammar test for genitive case'
223 }
224 ],
225
226
227 hu: [
228 {
229 word: 'Wikipédiá',
230 grammarForm: 'rol',
231 expected: 'Wikipédiáról',
232 description: 'Grammar test for rol case'
233 },
234 {
235 word: 'Wikipédiá',
236 grammarForm: 'ba',
237 expected: 'Wikipédiába',
238 description: 'Grammar test for ba case'
239 },
240 {
241 word: 'Wikipédiá',
242 grammarForm: 'k',
243 expected: 'Wikipédiák',
244 description: 'Grammar test for k case'
245 }
246 ],
247
248 ga: [
249 {
250 word: 'an Domhnach',
251 grammarForm: 'ainmlae',
252 expected: 'Dé Domhnaigh',
253 description: 'Grammar test for ainmlae case'
254 },
255 {
256 word: 'an Luan',
257 grammarForm: 'ainmlae',
258 expected: 'Dé Luain',
259 description: 'Grammar test for ainmlae case'
260 },
261 {
262 word: 'an Satharn',
263 grammarForm: 'ainmlae',
264 expected: 'Dé Sathairn',
265 description: 'Grammar test for ainmlae case'
266 }
267 ],
268
269 uk: [
270 {
271 word: 'тесть',
272 grammarForm: 'genitive',
273 expected: 'тестя',
274 description: 'Grammar test for genitive case'
275 },
276 {
277 word: 'Вікіпедія',
278 grammarForm: 'genitive',
279 expected: 'Вікіпедії',
280 description: 'Grammar test for genitive case'
281 },
282 {
283 word: 'установка',
284 grammarForm: 'genitive',
285 expected: 'установки',
286 description: 'Grammar test for genitive case'
287 },
288 {
289 word: 'похоти',
290 grammarForm: 'genitive',
291 expected: 'похотей',
292 description: 'Grammar test for genitive case'
293 },
294 {
295 word: 'доводы',
296 grammarForm: 'genitive',
297 expected: 'доводов',
298 description: 'Grammar test for genitive case'
299 },
300 {
301 word: 'песчаник',
302 grammarForm: 'genitive',
303 expected: 'песчаника',
304 description: 'Grammar test for genitive case'
305 },
306 {
307 word: 'Вікіпедія',
308 grammarForm: 'accusative',
309 expected: 'Вікіпедію',
310 description: 'Grammar test for accusative case'
311 }
312 ],
313
314 sl: [
315 {
316 word: 'word',
317 grammarForm: 'orodnik',
318 expected: 'z word',
319 description: 'Grammar test for orodnik case'
320 },
321 {
322 word: 'word',
323 grammarForm: 'mestnik',
324 expected: 'o word',
325 description: 'Grammar test for mestnik case'
326 }
327 ],
328
329 os: [
330 {
331 word: 'бæстæ',
332 grammarForm: 'genitive',
333 expected: 'бæсты',
334 description: 'Grammar test for genitive case'
335 },
336 {
337 word: 'бæстæ',
338 grammarForm: 'allative',
339 expected: 'бæстæм',
340 description: 'Grammar test for allative case'
341 },
342 {
343 word: 'Тигр',
344 grammarForm: 'dative',
345 expected: 'Тигрæн',
346 description: 'Grammar test for dative case'
347 },
348 {
349 word: 'цъити',
350 grammarForm: 'dative',
351 expected: 'цъитийæн',
352 description: 'Grammar test for dative case'
353 },
354 {
355 word: 'лæппу',
356 grammarForm: 'genitive',
357 expected: 'лæппуйы',
358 description: 'Grammar test for genitive case'
359 },
360 {
361 word: '2011',
362 grammarForm: 'equative',
363 expected: '2011-ау',
364 description: 'Grammar test for equative case'
365 }
366 ],
367
368 la: [
369 {
370 word: 'Translatio',
371 grammarForm: 'genitive',
372 expected: 'Translationis',
373 description: 'Grammar test for genitive case'
374 },
375 {
376 word: 'Translatio',
377 grammarForm: 'accusative',
378 expected: 'Translationem',
379 description: 'Grammar test for accusative case'
380 },
381 {
382 word: 'Translatio',
383 grammarForm: 'ablative',
384 expected: 'Translatione',
385 description: 'Grammar test for ablative case'
386 }
387 ]
388 };
389
390 $.each( grammarTests, function ( langCode, test ) {
391 if ( langCode === mw.config.get( 'wgUserLanguage' ) ) {
392 grammarTest( langCode, test );
393 }
394 });