mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-25 00:25:47 +00:00
5e98e3bcd6
When opening the lightbox, the image might stay small because of a race condition. This is fixed using a deferred object. Change-Id: I4e93c7d26da47e5177abeb1dac841bf6c25a9022 Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/138
30 lines
902 B
JavaScript
30 lines
902 B
JavaScript
( function ( /** mw, $ ** Commentted to keep lint happy, uncomment when needed */) {
|
|
QUnit.module( 'multilightbox.image', QUnit.newMwEnvironment() );
|
|
|
|
QUnit.asyncTest( 'Sanity test, object creation and image loading', 1, function ( assert ) {
|
|
var lightboxImage = new window.LightboxImage( 'http://en.wikipedia.org/w/skins/vector/images/search-ltr.png' );
|
|
|
|
// Function to be called if loading is successful
|
|
function loadCallback() {
|
|
assert.ok( true, 'Image loaded !' );
|
|
QUnit.start();
|
|
}
|
|
|
|
lightboxImage.getImageElement()
|
|
.done( loadCallback );
|
|
} );
|
|
|
|
QUnit.asyncTest( 'Image failing', 1, function ( assert ) {
|
|
var lightboxImage = new window.LightboxImage( 'http://thisdoesntexist/fail.jpg' );
|
|
|
|
function errorCallback() {
|
|
assert.ok( true, 'Image failed !' );
|
|
QUnit.start();
|
|
}
|
|
|
|
lightboxImage.getImageElement()
|
|
.fail( errorCallback );
|
|
} );
|
|
|
|
}( mediaWiki, jQuery ) );
|