Index: branches/jsgrammar/tests/qunit/QUnitTestResources.php |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | 'tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js', |
28 | 28 | 'tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js', |
29 | 29 | "tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js", |
| 30 | + "tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js", |
30 | 31 | ), |
31 | 32 | 'dependencies' => array( |
32 | 33 | 'jquery.autoEllipsis', |
— | — | @@ -42,6 +43,7 @@ |
43 | 44 | 'jquery.tablesorter', |
44 | 45 | 'jquery.textSelection', |
45 | 46 | 'mediawiki', |
| 47 | + 'language', |
46 | 48 | 'mediawiki.Title', |
47 | 49 | 'mediawiki.user', |
48 | 50 | 'mediawiki.util', |
Index: branches/jsgrammar/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js |
— | — | @@ -0,0 +1,43 @@ |
| 2 | +module( 'mediawiki.language' ); |
| 3 | + |
| 4 | +test( '-- Initial check', function() { |
| 5 | + expect( 1 ); |
| 6 | + ok( mw.language, 'mw.language defined' ); |
| 7 | +} ); |
| 8 | + |
| 9 | + |
| 10 | +mw.language.grammartest = function( options ) { |
| 11 | + var opt = $.extend({ |
| 12 | + language: '', |
| 13 | + grammarForm: null, |
| 14 | + word: '', |
| 15 | + expected: '', |
| 16 | + description: '' |
| 17 | + }, options); |
| 18 | + // The test works only if the content language is opt.language |
| 19 | + // because it require [lang].js to be loaded. |
| 20 | + if( mw.config.get ( 'wgContentLanguage' ) === opt.language ) { |
| 21 | + test( opt.description, function() { |
| 22 | + expect( 1 ); |
| 23 | + var langData = mw.language.data; |
| 24 | + var grammarForms = []; |
| 25 | + grammarForms[ opt.grammarForm ] = [] ; |
| 26 | + if ( langData[opt.language] === undefined ) { |
| 27 | + langData[opt.language] = new mw.Map(); |
| 28 | + }else{ |
| 29 | + grammarForms = langData[opt.language].get( 'grammarForms' ); |
| 30 | + } |
| 31 | + grammarForms[opt.grammarForm][opt.word] = opt.expected ; |
| 32 | + langData[opt.language].set( 'grammarForms', grammarForms ); |
| 33 | + equal( mw.language.convertGrammar( opt.word, opt.grammarForm ), opt.expected, opt.description ); |
| 34 | + } ); |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +mw.language.grammartest({ |
| 39 | + language: 'en', |
| 40 | + word: 'pen', |
| 41 | + grammarForm: 'genitive', |
| 42 | + expected: 'pen\'s', |
| 43 | + description: 'Grammar test for English' |
| 44 | +}); |
Property changes on: branches/jsgrammar/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 45 | + native |