Debian Codegraph @

tests/qunit/resources/startup/jscompat.test.js

raw symbols SCIP
1 // JavaScript compatibility tests to confirm that server and browser
2 // are behaving consistently and configured correctly.
3 QUnit.module( 'startup/jscompat', () => {
4
5 QUnit.test( 'Unicode variable name', ( assert ) => {
6 const ŝablono = true;
7
8 assert.true( ŝablono, 'ŝablono' );
9 assert.true( \u015dablono, '\\u015dablono' );
10 assert.true( \u015Dablono, '\\u015Dablono' );
11 } );
12
13 function repeat( str, n ) {
14 let out;
15 if ( n <= 0 ) {
16 return '';
17 } else {
18 out = [];
19 out.length = n + 1;
20 return out.join( str );
21 }
22 }
23
24 QUnit.test.each( 'textarea strips newline (T14130)', [ 0, 1, 2, 3 ], ( assert, i ) => {
25 const expected = repeat( '\n', i ) + 'some text';
26
27 let $textarea;
28 // When setting HTML, we expect exactly 1 newline to be stripped.
29 $textarea = $( '<textarea>\n' + expected + '</textarea>' );
30 assert.strictEqual( $textarea.val(), expected, 'read after setting HTML' );
31
32 $textarea = $( '<textarea>' ).val( expected );
33 assert.strictEqual( $textarea.val(), expected, 'read after setting value' );
34 } );
35 } );