2014-02-25 01:54:05 +00:00
|
|
|
( function ( mw ) {
|
|
|
|
QUnit.module( 'mmv.lightboximage', QUnit.newMwEnvironment() );
|
2013-12-09 20:18:40 +00:00
|
|
|
|
|
|
|
QUnit.asyncTest( 'Sanity test, object creation and image loading', 1, function ( assert ) {
|
2014-02-25 01:54:05 +00:00
|
|
|
var lightboxImage = new mw.LightboxImage( 'http://en.wikipedia.org/w/skins/vector/images/search-ltr.png' );
|
2013-12-09 20:18:40 +00:00
|
|
|
|
|
|
|
// Function to be called if loading is successful
|
|
|
|
function loadCallback() {
|
|
|
|
assert.ok( true, 'Image loaded !' );
|
|
|
|
QUnit.start();
|
|
|
|
}
|
|
|
|
|
2014-01-15 23:33:16 +00:00
|
|
|
lightboxImage.getImageElement()
|
|
|
|
.done( loadCallback );
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.asyncTest( 'Image failing', 1, function ( assert ) {
|
2014-02-25 01:54:05 +00:00
|
|
|
var lightboxImage = new mw.LightboxImage( 'fail' );
|
2014-01-15 23:33:16 +00:00
|
|
|
|
|
|
|
function errorCallback() {
|
|
|
|
assert.ok( true, 'Image failed !' );
|
|
|
|
QUnit.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
lightboxImage.getImageElement()
|
|
|
|
.fail( errorCallback );
|
2013-12-09 20:18:40 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
}( mediaWiki, jQuery ) );
|