(bug 37755) Set robot meta tags for 'view source' pages
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.mwExtension.test.js
1 QUnit.module( 'jquery.mwExtension', QUnit.newMwEnvironment() );
2
3 QUnit.test( 'String functions', function ( assert ) {
4
5 assert.equal( $.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' );
6 assert.equal( $.trimRight( ' foo bar ' ), ' foo bar', 'trimRight' );
7 assert.equal( $.ucFirst( 'foo' ), 'Foo', 'ucFirst' );
8
9 assert.equal( $.escapeRE( '<!-- ([{+mW+}]) $^|?>' ),
10 '<!\\-\\- \\(\\[\\{\\+mW\\+\\}\\]\\) \\$\\^\\|\\?>', 'escapeRE - Escape specials' );
11 assert.equal( $.escapeRE( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ),
12 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'escapeRE - Leave uppercase alone' );
13 assert.equal( $.escapeRE( 'abcdefghijklmnopqrstuvwxyz' ),
14 'abcdefghijklmnopqrstuvwxyz', 'escapeRE - Leave lowercase alone' );
15 assert.equal( $.escapeRE( '0123456789' ), '0123456789', 'escapeRE - Leave numbers alone' );
16 });
17
18 QUnit.test( 'Is functions', function ( assert ) {
19
20 assert.strictEqual( $.isDomElement( document.getElementById( 'qunit-header' ) ), true,
21 'isDomElement: #qunit-header Node' );
22 assert.strictEqual( $.isDomElement( document.getElementById( 'random-name' ) ), false,
23 'isDomElement: #random-name (null)' );
24 assert.strictEqual( $.isDomElement( document.getElementsByTagName( 'div' ) ), false,
25 'isDomElement: getElementsByTagName Array' );
26 assert.strictEqual( $.isDomElement( document.getElementsByTagName( 'div' )[0] ), true,
27 'isDomElement: getElementsByTagName(..)[0] Node' );
28 assert.strictEqual( $.isDomElement( $( 'div' ) ), false,
29 'isDomElement: jQuery object' );
30 assert.strictEqual( $.isDomElement( $( 'div' ).get(0) ), true,
31 'isDomElement: jQuery object > Get node' );
32 assert.strictEqual( $.isDomElement( document.createElement( 'div' ) ), true,
33 'isDomElement: createElement' );
34 assert.strictEqual( $.isDomElement( { foo: 1 } ), false,
35 'isDomElement: Object' );
36
37 assert.strictEqual( $.isEmpty( 'string' ), false, 'isEmptry: "string"' );
38 assert.strictEqual( $.isEmpty( '0' ), true, 'isEmptry: "0"' );
39 assert.strictEqual( $.isEmpty( '' ), true, 'isEmptry: ""' );
40 assert.strictEqual( $.isEmpty( 1 ), false, 'isEmptry: 1' );
41 assert.strictEqual( $.isEmpty( [] ), true, 'isEmptry: []' );
42 assert.strictEqual( $.isEmpty( {} ), true, 'isEmptry: {}' );
43
44 // Documented behaviour
45 assert.strictEqual( $.isEmpty( { length: 0 } ), true, 'isEmptry: { length: 0 }' );
46 });
47
48 QUnit.test( 'Comparison functions', function ( assert ) {
49
50 assert.ok( $.compareArray( [0, 'a', [], [2, 'b'] ], [0, "a", [], [2, "b"] ] ),
51 'compareArray: Two deep arrays that are excactly the same' );
52 assert.ok( !$.compareArray( [1], [2] ), 'compareArray: Two different arrays (false)' );
53
54 assert.ok( $.compareObject( {}, {} ), 'compareObject: Two empty objects' );
55 assert.ok( $.compareObject( { foo: 1 }, { foo: 1 } ), 'compareObject: Two the same objects' );
56 assert.ok( !$.compareObject( { bar: true }, { baz: false } ),
57 'compareObject: Two different objects (false)' );
58 });