registration: Only allow one extension to set a specific config setting
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.mwExtension.test.js
1 ( function ( $ ) {
2 QUnit.module( 'jquery.mwExtension', QUnit.newMwEnvironment( {
3 // This entire module is deprecated.
4 // Surpress deprecation warnings in test output.
5 setup: function () {
6 this.suppressWarnings();
7 },
8 teardown: function () {
9 this.restoreWarnings();
10 }
11 } ) );
12
13 QUnit.test( 'String functions', function ( assert ) {
14 assert.equal( $.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' );
15 assert.equal( $.trimRight( ' foo bar ' ), ' foo bar', 'trimRight' );
16 assert.equal( $.ucFirst( 'foo' ), 'Foo', 'ucFirst' );
17
18 assert.equal( $.escapeRE( '<!-- ([{+mW+}]) $^|?>' ),
19 '<!\\-\\- \\(\\[\\{\\+mW\\+\\}\\]\\) \\$\\^\\|\\?>', 'escapeRE - Escape specials' );
20 assert.equal( $.escapeRE( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ),
21 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'escapeRE - Leave uppercase alone' );
22 assert.equal( $.escapeRE( 'abcdefghijklmnopqrstuvwxyz' ),
23 'abcdefghijklmnopqrstuvwxyz', 'escapeRE - Leave lowercase alone' );
24 assert.equal( $.escapeRE( '0123456789' ), '0123456789', 'escapeRE - Leave numbers alone' );
25 } );
26
27 QUnit.test( 'isDomElement', function ( assert ) {
28 assert.strictEqual( $.isDomElement( document.createElement( 'div' ) ), true,
29 'isDomElement: HTMLElement' );
30 assert.strictEqual( $.isDomElement( document.createTextNode( '' ) ), true,
31 'isDomElement: TextNode' );
32 assert.strictEqual( $.isDomElement( null ), false,
33 'isDomElement: null' );
34 assert.strictEqual( $.isDomElement( document.getElementsByTagName( 'div' ) ), false,
35 'isDomElement: NodeList' );
36 assert.strictEqual( $.isDomElement( $( 'div' ) ), false,
37 'isDomElement: jQuery' );
38 assert.strictEqual( $.isDomElement( { foo: 1 } ), false,
39 'isDomElement: Plain Object' );
40 } );
41
42 QUnit.test( 'isEmpty', function ( assert ) {
43 assert.strictEqual( $.isEmpty( 'string' ), false, 'isEmpty: "string"' );
44 assert.strictEqual( $.isEmpty( '0' ), true, 'isEmpty: "0"' );
45 assert.strictEqual( $.isEmpty( '' ), true, 'isEmpty: ""' );
46 assert.strictEqual( $.isEmpty( 1 ), false, 'isEmpty: 1' );
47 assert.strictEqual( $.isEmpty( [] ), true, 'isEmpty: []' );
48 assert.strictEqual( $.isEmpty( {} ), true, 'isEmpty: {}' );
49
50 // Documented behavior
51 assert.strictEqual( $.isEmpty( { length: 0 } ), true, 'isEmpty: { length: 0 }' );
52 } );
53
54 QUnit.test( 'Comparison functions', function ( assert ) {
55 assert.ok( $.compareArray( [ 0, 'a', [], [ 2, 'b' ] ], [ 0, 'a', [], [ 2, 'b' ] ] ),
56 'compareArray: Two deep arrays that are excactly the same' );
57 assert.ok( !$.compareArray( [ 1 ], [ 2 ] ), 'compareArray: Two different arrays (false)' );
58
59 assert.ok( $.compareObject( {}, {} ), 'compareObject: Two empty objects' );
60 assert.ok( $.compareObject( { foo: 1 }, { foo: 1 } ), 'compareObject: Two the same objects' );
61 assert.ok( !$.compareObject( { bar: true }, { baz: false } ),
62 'compareObject: Two different objects (false)' );
63 } );
64 }( jQuery ) );