r111990 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111989‎ | r111990 | r111991 >
Date:04:55, 21 February 2012
Author:amire80
Status:resolved
Tags:i18nreview 
Comment:
Adding more tests for initialization, transliteration and cookies.
Modified paths:
  • /trunk/extensions/Narayam/tests/qunit/ext.narayam.tests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Narayam/tests/qunit/ext.narayam.tests.js
@@ -11,21 +11,31 @@
1212
1313 module( "ext.narayam", QUnit.newMwEnvironment() );
1414
15 -// A language that definitely has input methods
16 -mw.config.set( { wgUserLanguage: "ml" } );
17 -
1815 function setup() {
1916 $.narayam.setup();
2017 $.narayam.enable();
2118 }
 19+
2220 function teardown() {
23 - // we need to disable narayam, otherwise many typing simulation based test eg: jquery.byteLimitTest will fail.
 21+ // We need to disable narayam, otherwise many typing simulation based
 22+ // tests, like jquery.byteLimitTest, will fail.
2423 $.narayam.disable();
2524 }
 25+
2626 test( "-- Initial check", function() {
27 - expect( 1 );
 27+ expect( 2 );
2828
 29+ // Clean up before testing initialization
 30+ teardown();
 31+ // Delete state cookie
 32+ $.cookie( 'narayam-enabled', null );
 33+
 34+ setup();
2935 ok( $.narayam, "$.narayam is defined" );
 36+ equals( $.narayam.enabled(), mw.config.get( 'wgNarayamEnabledByDefault' ), 'Initial state of Narayam matches the configuration' );
 37+
 38+ // Init empty cookie of recent schemes
 39+ $.cookie( 'narayam-scheme', '', { path: '/', expires: 30 } );
3040 } );
3141
3242 test( "-- Initialization functions", function() {
@@ -77,4 +87,54 @@
7888 teardown();
7989 } );
8090
 91+test( '-- German transliteration and keybuffers', function() {
 92+ expect( 3 );
 93+ setup();
 94+
 95+ // Testing keybuffer ("compose key")
 96+ $.narayam.setScheme( 'de' );
 97+ equals( $.narayam.transliterate( '~o', '~', false ), 'ö', 'German ~o -> ö' );
 98+ equals( $.narayam.transliterate( '~O', '~', false ), 'Ö', 'German ~O -> Ö' );
 99+ equals( $.narayam.transliterate( '~s', '~', false ), 'ß', 'German ~s -> ß' );
 100+
 101+ teardown();
 102+} );
 103+
 104+test( '-- Hebrew transliteration, extended keyboard', function() {
 105+ expect( 2 );
 106+ setup();
 107+
 108+ // Testing extended and non-extended
 109+ $.narayam.setScheme( 'he-standard-2011-extonly' );
 110+ equals( $.narayam.transliterate( '=', '', false ), '=', 'Hebrew non-extended = does not change' );
 111+ equals( $.narayam.transliterate( '=', '', true ), '–', 'Hebrew extended = becomes en dash' );
 112+
 113+ teardown();
 114+} );
 115+
 116+test( '-- Malayalam transliteration, cookie, zwnj, longer keybuffers', function() {
 117+ expect( 8 );
 118+ setup();
 119+
 120+ $.narayam.setScheme( 'kn' );
 121+ var recentSchemes = $.cookie( 'narayam-scheme' ),
 122+ currentSchemeRegex = new RegExp( '^kn' );
 123+ ok ( currentSchemeRegex.test( recentSchemes ), 'New scheme added to the cookie' );
 124+
 125+ $.narayam.setScheme( 'ml' );
 126+
 127+ equals( $.narayam.transliterate( 'a', '', false ), 'അ', 'Malayalam a -> അ' );
 128+
 129+ // N.B.: There's a zwnj in the input, and no zwnj in the expected result
 130+ equals( $.narayam.transliterate( 'നീല‌a', '', false ), 'നീലഅ', 'Malayalam zwnj+a -> അ' );
 131+ equals( $.narayam.transliterate( 'ൻൿh', 'nc', false ), 'ഞ്ച്', 'Malayalam nch -> ഞ്ച്' );
 132+
 133+ equals( $.narayam.transliterate( 'p', '', false ), 'പ്', 'Malayalam p -> പ്' );
 134+ equals( $.narayam.transliterate( 'പ്a', '', false ), 'പ', 'Malayalam pa -> പ' );
 135+ equals( $.narayam.transliterate( 'ക്h', '', false ), 'ഖ്', 'Malayalam kh -> ഖ്' );
 136+ equals( $.narayam.transliterate( 'ഖ്a', '', false ), 'ഖ', 'Malayalam kha -> ഖ്' );
 137+
 138+ teardown();
 139+} );
 140+
81141 }());

Sign-offs

UserFlagDate
Nikerabbitinspected09:24, 21 February 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r111995Make the input method rules of Narayam testable....santhosh09:32, 21 February 2012

Status & tagging log