Merge "Stash WatchedItem changes so that the jobs run from the queue"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.loader.test.js
index cb028a9..e17c78d 100644 (file)
@@ -15,6 +15,7 @@
                        };
                },
                teardown: function () {
+                       mw.loader.maxQueryLength = 2000;
                        // Teardown for StringSet shim test
                        if ( this.nativeSet ) {
                                window.Set = this.nativeSet;
@@ -24,6 +25,7 @@
                        // exposed for cross-file mocks.
                        delete mw.loader.testCallback;
                        delete mw.loader.testFail;
+                       delete mw.getScriptExampleScriptLoaded;
                }
        } ) );
 
                        [ 'testUrlIncDump', 'dump', [], null, 'testloader' ]
                ] );
 
-               mw.config.set( 'wgResourceLoaderMaxQueryLength', 10 );
+               mw.loader.maxQueryLength = 10;
 
                return mw.loader.using( [ 'testUrlIncDump', 'testUrlInc' ] ).then( function ( require ) {
                        assert.propEqual(
                } );
        } );
 
+       QUnit.test( '.getScript() - success', function ( assert ) {
+               var scriptUrl = QUnit.fixurl(
+                       mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/mediawiki.loader.getScript.example.js'
+               );
+
+               return mw.loader.getScript( scriptUrl ).then(
+                       function () {
+                               assert.strictEqual( mw.getScriptExampleScriptLoaded, true, 'Data attached to a global object is available' );
+                       }
+               );
+       } );
+
+       QUnit.test( '.getScript() - failure', function ( assert ) {
+               assert.rejects(
+                       mw.loader.getScript( 'https://example.test/not-found' ),
+                       /Failed to load script/,
+                       'Descriptive error message'
+               );
+       } );
+
 }() );