Index: trunk/extensions/Narayam/tests/qunit/ext.narayam.rules.tests.js |
— | — | @@ -25,15 +25,35 @@ |
26 | 26 | } ); |
27 | 27 | |
28 | 28 | // 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; |
31 | 35 | for ( var i = 0; i < len; i++ ) { |
32 | 36 | // 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 | + |
34 | 49 | // 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 | + } ); |
36 | 56 | if( $input.triggerHandler( event ) ) { |
37 | | - $input.val( $input.val() + charstr[i] ) ; |
| 57 | + $input.val( $input.val() + character ) ; |
38 | 58 | } |
39 | 59 | } |
40 | 60 | }; |
— | — | @@ -140,8 +160,9 @@ |
141 | 161 | { input: 'dny', output: 'ज्ञ्', description: 'dny for ज्ञ् in Marathi transliteration' } |
142 | 162 | ], |
143 | 163 | scheme: 'mr', |
144 | | - $input: $( '<input>' ).attr( { id: "mr", type: 'text' } ) |
| 164 | + $input: $( '<input>' ).attr( { id: 'mr', type: 'text' } ) |
145 | 165 | } ); |
| 166 | + |
146 | 167 | narayamTest( { |
147 | 168 | description: 'German Transliteration and keybuffer test', |
148 | 169 | tests: [ |
— | — | @@ -152,6 +173,17 @@ |
153 | 174 | scheme: 'de', |
154 | 175 | $input: $( '<input>' ).attr( { id: 'de', type: 'text' } ) |
155 | 176 | } ); |
| 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 | + |
156 | 188 | teardown( ); |
157 | 189 | |
158 | 190 | }() ); |