r114273 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114272‎ | r114273 | r114274 >
Date:14:23, 20 March 2012
Author:amire80
Status:ok
Tags:
Comment:
Added the ability to test extended keyboard layouts.
Added tests for Hebrew extended keys.
Made "mr" string more consistent.
Modified paths:
  • /trunk/extensions/Narayam/tests/qunit/ext.narayam.rules.tests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Narayam/tests/qunit/ext.narayam.rules.tests.js
@@ -25,15 +25,35 @@
2626 } );
2727
2828 // Basic sendkey-implementation
29 -typeChars = function( $input, charstr ) {
30 - var len = charstr.length;
 29+// $input - the input element
 30+// characters - either
 31+// - a string
 32+// - an array of pairs of character and altKey value
 33+typeChars = function( $input, characters ) {
 34+ var len = characters.length;
3135 for ( var i = 0; i < len; i++ ) {
3236 // Get the key code
33 - var code = charstr.charCodeAt(i);
 37+ var character,
 38+ altKeyValue;
 39+ if ( typeof( characters ) === 'string' ) {
 40+ character = characters[i];
 41+ altKeyValue = false;
 42+ } else {
 43+ character = characters[i][0];
 44+ altKeyValue = characters[i][1];
 45+ }
 46+
 47+ var code = character.charCodeAt(0);
 48+
3449 // Trigger event and undo if prevented
35 - var event = new jQuery.Event( 'keypress', { keyCode: code, which: code, charCode: code } );
 50+ var event = new jQuery.Event( 'keypress', {
 51+ keyCode: code,
 52+ which: code,
 53+ charCode: code,
 54+ altKey: altKeyValue
 55+ } );
3656 if( $input.triggerHandler( event ) ) {
37 - $input.val( $input.val() + charstr[i] ) ;
 57+ $input.val( $input.val() + character ) ;
3858 }
3959 }
4060 };
@@ -140,8 +160,9 @@
141161 { input: 'dny', output: 'ज्ञ्', description: 'dny for ज्ञ् in Marathi transliteration' }
142162 ],
143163 scheme: 'mr',
144 - $input: $( '<input>' ).attr( { id: "mr", type: 'text' } )
 164+ $input: $( '<input>' ).attr( { id: 'mr', type: 'text' } )
145165 } );
 166+
146167 narayamTest( {
147168 description: 'German Transliteration and keybuffer test',
148169 tests: [
@@ -152,6 +173,17 @@
153174 scheme: 'de',
154175 $input: $( '<input>' ).attr( { id: 'de', type: 'text' } )
155176 } );
 177+
 178+narayamTest( {
 179+ description: 'Hebrew Transliteration and extended keys test',
 180+ tests: [
 181+ { input: [ [ '-', false ] ], output: '-', description: 'Hebrew regular -' },
 182+ { input: [ [ '-', true ] ], output: '־', description: 'Hebrew extended -' }
 183+ ],
 184+ scheme: 'he-standard-2011-extonly',
 185+ $input: $( '<input>' ).attr( { id: 'he-standard-2011-extonly', type: 'text' } )
 186+} );
 187+
156188 teardown( );
157189
158190 }() );

Follow-up revisions

RevisionCommit summaryAuthorDate
r114274Added a comment, follow up to r114273.amire8014:45, 20 March 2012

Status & tagging log