Merge "Replace infobox usages and extend successbox, warningbox and errorbox"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.loader.test.js
index 3258f8e..16c3183 100644 (file)
                        [ 'test.load.circleB', '0', [ 'test.load.circleC' ] ],
                        [ 'test.load.circleC', '0', [ 'test.load.circleA' ] ]
                ] );
-               this.sandbox.stub( mw, 'track', function ( topic, data ) {
+               this.sandbox.stub( mw, 'trackError', function ( topic, data ) {
                        capture.push( {
                                topic: topic,
                                error: data.exception && data.exception.message,
                mw.loader.register( [
                        [ 'test.load.circleDirect', '0', [ 'test.load.circleDirect' ] ]
                ] );
-               this.sandbox.stub( mw, 'track', function ( topic, data ) {
+               this.sandbox.stub( mw, 'trackError', function ( topic, data ) {
                        capture.push( {
                                topic: topic,
                                error: data.exception && data.exception.message,
 
        QUnit.test( '.load() - Error: Unregistered', function ( assert ) {
                var capture = [];
-               this.sandbox.stub( mw, 'track', function ( topic, data ) {
-                       capture.push( {
-                               topic: topic,
-                               error: data.exception && data.exception.message,
-                               source: data.source
-                       } );
+               this.sandbox.stub( mw.log, 'warn', function ( str ) {
+                       capture.push( str );
                } );
 
                mw.loader.load( 'test.load.unreg' );
-               assert.deepEqual(
-                       [ {
-                               topic: 'resourceloader.exception',
-                               error: 'Unknown module: test.load.unreg',
-                               source: 'resolve'
-                       } ],
-                       capture
-               );
+               assert.deepEqual( capture, [ 'Skipped unresolvable module test.load.unreg' ] );
        } );
 
        // Regression test for T36853
        QUnit.test( '.load() - Error: Missing dependency', function ( assert ) {
                var capture = [];
-               this.sandbox.stub( mw, 'track', function ( topic, data ) {
+               this.sandbox.stub( mw, 'trackError', function ( topic, data ) {
                        capture.push( {
                                topic: topic,
                                error: data.exception && data.exception.message,
                                require( 'testUrlIncDump' ).query,
                                {
                                        modules: 'testUrlIncDump',
-                                       // Expected: Wrapped hash just for this one module
-                                       //   $hash = hash( 'fnv132', 'dump');
-                                       //   base_convert( $hash, 16, 36 ); // "13e9zzn"
-                                       // Previously: Wrapped hash for both modules, despite being in separate requests
-                                       //   $hash = hash( 'fnv132', 'urldump' );
-                                       //   base_convert( $hash, 16, 36 ); // "18kz9ca"
-                                       version: '13e9zzn'
+                                       // Expected: Combine hashes only for the module in the specific HTTP request
+                                       //   hash fnv132 => "13e9zzn"
+                                       // Wrong: Combine hashes for all requested modules, before request-splitting
+                                       //   hash fnv132 => "18kz9ca"
+                                       version: '13e9z'
                                },
                                'Query parameters'
                        );
                                require( 'testUrlOrderDump' ).query,
                                {
                                        modules: 'testUrlOrder,testUrlOrderDump|testUrlOrder.a,b',
-                                       // Expected: Combined in order after string packing
-                                       //   $hash = hash( 'fnv132', 'urldump12' );
-                                       //   base_convert( $hash, 16, 36 ); // "1knqzan"
-                                       // Previously: Combined in order of before string packing
-                                       //   $hash = hash( 'fnv132', 'url12dump' );
-                                       //   base_convert( $hash, 16, 36 ); // "11eo3in"
-                                       version: '1knqzan'
+                                       // Expected: Combined by sorting names after string packing
+                                       //   hash fnv132 = "1knqzan"
+                                       // Wrong: Combined by sorting names before string packing
+                                       //   hash fnv132 => "11eo3in"
+                                       version: '1knqz'
                                },
                                'Query parameters'
                        );
                this.useStubClock();
 
                // Don't actually emit an error event
-               this.sandbox.stub( mw, 'track' );
+               this.sandbox.stub( mw, 'trackError' );
 
                mw.loader.register( [
                        [ 'test.module1', '0' ],
                }, {}, {} );
                this.tick();
 
-               assert.strictEqual( mw.loader.getState( 'test.module1' ), 'error', 'Expected "error" state for test.module1' );
-               assert.strictEqual( mw.loader.getState( 'test.module2' ), 'error', 'Expected "error" state for test.module2' );
-               assert.strictEqual( mw.loader.getState( 'test.module3' ), 'error', 'Expected "error" state for test.module3' );
+               assert.strictEqual( mw.loader.getState( 'test.module1' ), 'error', 'State of test.module1' );
+               assert.strictEqual( mw.loader.getState( 'test.module2' ), 'error', 'State of test.module2' );
+               assert.strictEqual( mw.loader.getState( 'test.module3' ), 'error', 'State of test.module3' );
 
-               assert.strictEqual( mw.track.callCount, 1 );
+               assert.strictEqual( mw.trackError.callCount, 1 );
        } );
 
        QUnit.test( 'Out-of-order implementation', function ( assert ) {
 
                mw.loader.implement( 'test.module4', function () {} );
                this.tick();
-               assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
-               assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
-               assert.strictEqual( mw.loader.getState( 'test.module6' ), 'registered', 'Expected "registered" state for test.module6' );
+               assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'State of test.module4' );
+               assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'State of test.module5' );
+               assert.strictEqual( mw.loader.getState( 'test.module6' ), 'registered', 'State of test.module6' );
 
                mw.loader.implement( 'test.module6', function () {} );
                this.tick();
-               assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
-               assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
-               assert.strictEqual( mw.loader.getState( 'test.module6' ), 'loaded', 'Expected "loaded" state for test.module6' );
+               assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'State of test.module4' );
+               assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'State of test.module5' );
+               assert.strictEqual( mw.loader.getState( 'test.module6' ), 'loaded', 'State of test.module6' );
 
                mw.loader.implement( 'test.module5', function () {} );
                this.tick();
-               assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
-               assert.strictEqual( mw.loader.getState( 'test.module5' ), 'ready', 'Expected "ready" state for test.module5' );
-               assert.strictEqual( mw.loader.getState( 'test.module6' ), 'ready', 'Expected "ready" state for test.module6' );
+               assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'State of test.module4' );
+               assert.strictEqual( mw.loader.getState( 'test.module5' ), 'ready', 'State of test.module5' );
+               assert.strictEqual( mw.loader.getState( 'test.module6' ), 'ready', 'State of test.module6' );
        } );
 
        QUnit.test( 'Missing dependency', function ( assert ) {