Merge "Revert "Setting up a way to have uploading by URL, but not on Special:Upload""
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.byteLength.test.js
1 QUnit.module( 'jquery.byteLength', QUnit.newMwEnvironment() );
2
3 QUnit.test( 'Simple text', 5, function ( assert ) {
4 var azLc = 'abcdefghijklmnopqrstuvwxyz',
5 azUc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
6 num = '0123456789',
7 x = '*',
8 space = ' ';
9
10 assert.equal( $.byteLength( azLc ), 26, 'Lowercase a-z' );
11 assert.equal( $.byteLength( azUc ), 26, 'Uppercase A-Z' );
12 assert.equal( $.byteLength( num ), 10, 'Numbers 0-9' );
13 assert.equal( $.byteLength( x ), 1, 'An asterisk' );
14 assert.equal( $.byteLength( space ), 3, '3 spaces' );
15
16 } );
17
18 QUnit.test( 'Special text', 5, function ( assert ) {
19 // http://en.wikipedia.org/wiki/UTF-8
20 var U_0024 = '\u0024',
21 U_00A2 = '\u00A2',
22 U_20AC = '\u20AC',
23 U_024B62 = '\u024B62',
24 // The normal one doesn't display properly, try the below which is the same
25 // according to http://www.fileformat.info/info/unicode/char/24B62/index.htm
26 U_024B62_alt = '\uD852\uDF62';
27
28 assert.strictEqual( $.byteLength( U_0024 ), 1, 'U+0024: 1 byte. \u0024 (dollar sign)' );
29 assert.strictEqual( $.byteLength( U_00A2 ), 2, 'U+00A2: 2 bytes. \u00A2 (cent sign)' );
30 assert.strictEqual( $.byteLength( U_20AC ), 3, 'U+20AC: 3 bytes. \u20AC (euro sign)' );
31 assert.strictEqual( $.byteLength( U_024B62 ), 4, 'U+024B62: 4 bytes. \uD852\uDF62 (a Han character)' );
32 assert.strictEqual( $.byteLength( U_024B62_alt ), 4, 'U+024B62: 4 bytes. \uD852\uDF62 (a Han character) - alternative method' );
33 } );