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=477b04dcc9ada879881c6a308871d0c96970afa3;hpb=bff08bb43949f24cb30eefc4acb972634aa621a8;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 477b04dcc9..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 ) { @@ -546,7 +606,7 @@ assert.ok( true, 'QUnit expected() count dummy' ); }, function ( e, dependencies ) { - assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' ); + assert.strictEqual( Array.isArray( dependencies ), true, 'Expected array of dependencies' ); assert.deepEqual( dependencies, [ 'test.module7' ], 'Error callback called with module test.module7' ); } ); @@ -557,7 +617,7 @@ assert.ok( true, 'QUnit expected() count dummy' ); }, function ( e, dependencies ) { - assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' ); + assert.strictEqual( Array.isArray( dependencies ), true, 'Expected array of dependencies' ); dependencies.sort(); assert.deepEqual( dependencies,