https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111990

Revision: 111990
Author:   amire80
Date:     2012-02-21 04:55:52 +0000 (Tue, 21 Feb 2012)
Log Message:
-----------
Adding more tests for initialization, transliteration and cookies.

Modified Paths:
--------------
    trunk/extensions/Narayam/tests/qunit/ext.narayam.tests.js

Modified: trunk/extensions/Narayam/tests/qunit/ext.narayam.tests.js
===================================================================
--- trunk/extensions/Narayam/tests/qunit/ext.narayam.tests.js   2012-02-21 
04:03:00 UTC (rev 111989)
+++ trunk/extensions/Narayam/tests/qunit/ext.narayam.tests.js   2012-02-21 
04:55:52 UTC (rev 111990)
@@ -11,21 +11,31 @@
 
 module( "ext.narayam", QUnit.newMwEnvironment() );
 
-// A language that definitely has input methods
-mw.config.set( { wgUserLanguage: "ml" } );
-
 function setup() {
        $.narayam.setup();
        $.narayam.enable();
 }
+
 function teardown() {
-       // we need to disable narayam, otherwise many typing simulation based 
test eg: jquery.byteLimitTest will fail.
+       // We need to disable narayam, otherwise many typing simulation based
+       // tests, like jquery.byteLimitTest, will fail.
        $.narayam.disable();
 }
+
 test( "-- Initial check", function() {
-       expect( 1 );
+       expect( 2 );
 
+       // Clean up before testing initialization
+       teardown();
+       // Delete state cookie
+       $.cookie( 'narayam-enabled', null );
+
+       setup();
        ok( $.narayam, "$.narayam is defined" );
+       equals( $.narayam.enabled(), mw.config.get( 'wgNarayamEnabledByDefault' 
), 'Initial state of Narayam matches the configuration' );
+
+       // Init empty cookie of recent schemes
+       $.cookie( 'narayam-scheme', '', { path: '/', expires: 30 } );
 } );
 
 test( "-- Initialization functions", function() {
@@ -77,4 +87,54 @@
        teardown();
 } );
 
+test( '-- German transliteration and keybuffers', function() {
+       expect( 3 );
+       setup();
+
+       // Testing keybuffer ("compose key")
+       $.narayam.setScheme( 'de' );
+       equals( $.narayam.transliterate( '~o', '~', false ), 'ö', 'German ~o -> 
ö' );
+       equals( $.narayam.transliterate( '~O', '~', false ), 'Ö', 'German ~O -> 
Ö' );
+       equals( $.narayam.transliterate( '~s', '~', false ), 'ß', 'German ~s -> 
ß' );
+
+       teardown();
+} );
+
+test( '-- Hebrew transliteration, extended keyboard', function() {
+       expect( 2 );
+       setup();
+
+       // Testing extended and non-extended
+       $.narayam.setScheme( 'he-standard-2011-extonly' );
+       equals( $.narayam.transliterate( '=', '', false ), '=', 'Hebrew 
non-extended = does not change' );
+       equals( $.narayam.transliterate( '=', '', true ), '–', 'Hebrew extended 
= becomes en dash' );
+
+       teardown();
+} );
+
+test( '-- Malayalam transliteration, cookie, zwnj, longer keybuffers', 
function() {
+       expect( 8 );
+       setup();
+
+       $.narayam.setScheme( 'kn' );
+       var recentSchemes = $.cookie( 'narayam-scheme' ),
+               currentSchemeRegex = new RegExp( '^kn' );
+       ok ( currentSchemeRegex.test( recentSchemes ), 'New scheme added to the 
cookie' );
+
+       $.narayam.setScheme( 'ml' );
+
+       equals( $.narayam.transliterate( 'a',  '', false ), 'അ', 'Malayalam a 
-> അ' );
+
+       // N.B.: There's a zwnj in the input, and no zwnj in the expected result
+       equals( $.narayam.transliterate( 'നീല‌a',  '', false ), 'നീലഅ', 
'Malayalam zwnj+a -> അ' );
+       equals( $.narayam.transliterate( 'ൻൿh',  'nc', false ), 'ഞ്ച്', 
'Malayalam nch -> ഞ്ച്' );
+
+       equals( $.narayam.transliterate( 'p', '', false ), 'പ്', 'Malayalam p 
-> പ്' );
+       equals( $.narayam.transliterate( 'പ്a', '', false ), 'പ', 'Malayalam pa 
-> പ' );
+       equals( $.narayam.transliterate( 'ക്h', '', false ), 'ഖ്', 'Malayalam 
kh -> ഖ്' );
+       equals( $.narayam.transliterate( 'ഖ്a', '', false ), 'ഖ', 'Malayalam 
kha -> ഖ്' );
+
+       teardown();
+} );
+
 }());


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to