X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fqunit%2Fsuites%2Fresources%2Fmediawiki%2Fmediawiki.loader.test.js;h=a00b3cb889626431df7e87d1b70045e56c9b8342;hb=7fe6ee10a12c175edda10d0f2f391e6d647ed995;hp=7a0de81d8e9f0810ef862529aab21449862bf027;hpb=6fbafe5494440f5c37686b250ed759f6a96271b9;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js index 7a0de81d8e..a00b3cb889 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js @@ -38,8 +38,10 @@ function isCssImportApplied() { // Trigger reflow, repaint, redraw, whatever (cross-browser) $element.css( 'height' ); + // eslint-disable-next-line no-unused-expressions el.innerHTML; el.className = el.className; + // eslint-disable-next-line no-unused-expressions document.documentElement.clientHeight; return $element.css( prop ) === val; @@ -189,14 +191,30 @@ } ); QUnit.test( '.load() - Error: Circular dependency', function ( assert ) { + var capture = []; mw.loader.register( [ [ 'test.circleA', '0', [ 'test.circleB' ] ], [ 'test.circleB', '0', [ 'test.circleC' ] ], [ 'test.circleC', '0', [ 'test.circleA' ] ] ] ); - assert.throws( function () { - mw.loader.load( 'test.circleC' ); - }, /Circular/, 'Detect circular dependency' ); + this.sandbox.stub( mw, 'track', function ( topic, data ) { + capture.push( { + topic: topic, + error: data.exception && data.exception.message, + source: data.source + } ); + } ); + + mw.loader.load( 'test.circleC' ); + assert.deepEqual( + [ { + topic: 'resourceloader.exception', + error: 'Circular reference detected: test.circleB -> test.circleC', + source: 'resolve' + } ], + capture, + 'Detect circular dependency' + ); } ); QUnit.test( '.using() - Error: Unregistered', function ( assert ) { @@ -212,9 +230,51 @@ ).always( done ); } ); - QUnit.test( '.load() - Error: Unregistered (ignored)', function ( assert ) { - assert.expect( 0 ); - mw.loader.load( 'test.using.unreg2' ); + 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 + } ); + } ); + + mw.loader.load( 'test.load.unreg' ); + assert.deepEqual( + [ { + topic: 'resourceloader.exception', + error: 'Unknown dependency: test.load.unreg', + source: 'resolve' + } ], + capture + ); + } ); + + // Regression test for T36853 + QUnit.test( '.load() - Error: Missing dependency', 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 + } ); + } ); + + mw.loader.register( [ + [ 'test.load.missingdep1', '0', [ 'test.load.missingdep2' ] ], + [ 'test.load.missingdep', '0', [ 'test.load.missingdep1' ] ] + ] ); + mw.loader.load( 'test.load.missingdep' ); + assert.deepEqual( + [ { + topic: 'resourceloader.exception', + error: 'Unknown dependency: test.load.missingdep2', + source: 'resolve' + } ], + capture + ); } ); QUnit.test( '.implement( styles={ "css": [text, ..] } )', function ( assert ) {