$moduleImplementations = [
'testUsesMissing' => "
mw.loader.implement( 'testUsesMissing', function () {
- QUnit.ok( false, 'Module usesMissing script should not run.' );
- QUnit.start();
+ mw.loader.testFail( 'Module usesMissing script should not run.' );
}, {}, {});
",
'testUsesNestedMissing' => "
mw.loader.implement( 'testUsesNestedMissing', function () {
- QUnit.ok( false, 'Module testUsesNestedMissing script should not run.' );
- QUnit.start();
+ mw.loader.testFail('Module testUsesNestedMissing script should not run.' );
}, {}, {});
",
'testSkipped' => "
mw.loader.implement( 'testSkipped', function () {
- QUnit.ok( false, 'Module testSkipped was supposed to be skipped.' );
+ mw.loader.testFail( false, 'Module testSkipped was supposed to be skipped.' );
}, {}, {});
",
( function ( mw, $ ) {
QUnit.module( 'mediawiki (mw.loader)', QUnit.newMwEnvironment( {
- setup: function () {
+ setup: function ( assert ) {
mw.loader.store.enabled = false;
+
+ // Expose for load.mock.php
+ mw.loader.testFail = function ( reason ) {
+ assert.ok( false, reason );
+ };
},
teardown: function () {
mw.loader.store.enabled = false;
window.Set = this.nativeSet;
mw.redefineFallbacksForTest();
}
+ // Remove any remaining temporary statics
+ // exposed for cross-file mocks.
+ if ( 'testCallback' in mw.loader ) {
+ delete mw.loader.testCallback;
+ }
+ if ( 'testFail' in mw.loader ) {
+ delete mw.loader.testFail;
+ }
}
} ) );
return mw.loader.using( 'test.callback', function () {
assert.strictEqual( isAwesomeDone, true, 'test.callback module should\'ve caused isAwesomeDone to be true' );
- delete mw.loader.testCallback;
-
}, function () {
assert.ok( false, 'Error callback fired while loader.using "test.callback" module' );
} );
return mw.loader.using( 'hasOwnProperty', function () {
assert.strictEqual( isAwesomeDone, true, 'hasOwnProperty module should\'ve caused isAwesomeDone to be true' );
- delete mw.loader.testCallback;
-
}, function () {
assert.ok( false, 'Error callback fired while loader.using "hasOwnProperty" module' );
} );
return mw.loader.using( 'test.promise' )
.done( function () {
assert.strictEqual( isAwesomeDone, true, 'test.promise module should\'ve caused isAwesomeDone to be true' );
- delete mw.loader.testCallback;
} )
.fail( function () {
assert.ok( false, 'Error callback fired while loader.using "test.promise" module' );
assert.equal( target.slice( 0, 2 ), '//', 'URL is protocol-relative' );
mw.loader.testCallback = function () {
+ // Ensure once, delete now
delete mw.loader.testCallback;
assert.ok( true, 'callback' );
done();
assert.equal( target.slice( 0, 1 ), '/', 'URL is relative to document root' );
mw.loader.testCallback = function () {
+ // Ensure once, delete now
delete mw.loader.testCallback;
assert.ok( true, 'callback' );
done();