mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-13 18:06:57 +00:00
build: Enable more qunit lint rules
Where appropriate, convert assert.ok to assert.strictEqual. Change-Id: I098ade9928958e8c2d36de221361d89b5c70ec35
This commit is contained in:
parent
2c3213485d
commit
dec9c6321c
|
@ -109,6 +109,21 @@
|
|||
* @property {mw.mmv.logging.ViewLogger} view -
|
||||
*/
|
||||
this.viewLogger = new mw.mmv.logging.ViewLogger( this.config, window, mw.mmv.actionLogger );
|
||||
|
||||
/**
|
||||
* Stores whether the real image was loaded and displayed already.
|
||||
* This is reset when paging, so it is not necessarily accurate.
|
||||
* @property {boolean}
|
||||
*/
|
||||
this.realThumbnailShown = false;
|
||||
|
||||
/**
|
||||
* Stores whether the a blurred placeholder is being displayed in place of the real image.
|
||||
* When a placeholder is displayed, but it is not blurred, this is false.
|
||||
* This is reset when paging, so it is not necessarily accurate.
|
||||
* @property {boolean}
|
||||
*/
|
||||
this.blurredThumbnailShown = false;
|
||||
}
|
||||
|
||||
MMVP = MultimediaViewer.prototype;
|
||||
|
@ -411,19 +426,7 @@
|
|||
* Resets the cross-request states needed to handle the blurred thumbnail logic.
|
||||
*/
|
||||
MMVP.resetBlurredThumbnailStates = function () {
|
||||
/**
|
||||
* Stores whether the real image was loaded and displayed already.
|
||||
* This is reset when paging, so it is not necessarily accurate.
|
||||
* @property {boolean}
|
||||
*/
|
||||
this.realThumbnailShown = false;
|
||||
|
||||
/**
|
||||
* Stores whether the a blurred placeholder is being displayed in place of the real image.
|
||||
* When a placeholder is displayed, but it is not blurred, this is false.
|
||||
* This is reset when paging, so it is not necessarily accurate.
|
||||
* @property {boolean}
|
||||
*/
|
||||
this.blurredThumbnailShown = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
"qunit": true
|
||||
},
|
||||
"rules": {
|
||||
"qunit/no-assert-equal": "error",
|
||||
"qunit/no-early-return": "error",
|
||||
"qunit/no-negated-ok": "error",
|
||||
"qunit/require-expect": 0
|
||||
},
|
||||
"plugins": [ "qunit" ]
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
clock.tick( 10 );
|
||||
|
||||
assert.strictEqual( mw.log.lastCall.args[ 0 ], unknownAction, 'Log message defaults to unknown key' );
|
||||
assert.ok( fakeEventLog.logEvent.called, 'event log has been recorded' );
|
||||
assert.strictEqual( fakeEventLog.logEvent.called, true, 'event log has been recorded' );
|
||||
|
||||
mw.log.reset();
|
||||
fakeEventLog.logEvent.reset();
|
||||
|
@ -32,7 +32,7 @@
|
|||
clock.tick( 10 );
|
||||
|
||||
assert.strictEqual( mw.log.lastCall.args[ 0 ], action1value, 'Log message is translated to its text' );
|
||||
assert.ok( fakeEventLog.logEvent.called, 'event log has been recorded' );
|
||||
assert.strictEqual( fakeEventLog.logEvent.called, true, 'event log has been recorded' );
|
||||
|
||||
mw.log.reset();
|
||||
fakeEventLog.logEvent.reset();
|
||||
|
@ -40,8 +40,8 @@
|
|||
logger.log( action1key, true );
|
||||
clock.tick( 10 );
|
||||
|
||||
assert.ok( !mw.log.called, 'No logging when disabled' );
|
||||
assert.ok( fakeEventLog.logEvent.called, 'event log has been recorded' );
|
||||
assert.strictEqual( mw.log.called, false, 'No logging when disabled' );
|
||||
assert.strictEqual( fakeEventLog.logEvent.called, true, 'event log has been recorded' );
|
||||
|
||||
clock.restore();
|
||||
} );
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
} catch ( e ) {
|
||||
assert.ok( true, 'Exception raised when calling start() without parameters' );
|
||||
}
|
||||
assert.ok( $.isEmptyObject( durationLogger.starts ), 'No events saved by DurationLogger' );
|
||||
assert.strictEqual( $.isEmptyObject( durationLogger.starts ), true, 'No events saved by DurationLogger' );
|
||||
|
||||
durationLogger.start( 'foo' );
|
||||
assert.strictEqual( durationLogger.starts.foo, 0, 'Event start saved' );
|
||||
|
@ -96,7 +96,7 @@
|
|||
durationLogger.stop( 'bar' );
|
||||
durationLogger.record( 'bar' );
|
||||
|
||||
assert.ok( !fakeEventLog.logEvent.called, 'Event queued if dependencies not loaded' );
|
||||
assert.strictEqual( fakeEventLog.logEvent.called, false, 'Event queued if dependencies not loaded' );
|
||||
|
||||
// Queue a second item
|
||||
|
||||
|
@ -105,7 +105,7 @@
|
|||
durationLogger.stop( 'bob' );
|
||||
durationLogger.record( 'bob' );
|
||||
|
||||
assert.ok( !fakeEventLog.logEvent.called, 'Event queued if dependencies not loaded' );
|
||||
assert.strictEqual( fakeEventLog.logEvent.called, false, 'Event queued if dependencies not loaded' );
|
||||
|
||||
dependenciesDeferred.resolve();
|
||||
this.clock.tick( 10 );
|
||||
|
|
|
@ -25,21 +25,21 @@
|
|||
|
||||
viewLogger.unview();
|
||||
|
||||
assert.ok( !logger.log.called, 'action logger not called' );
|
||||
assert.strictEqual( logger.log.called, false, 'action logger not called' );
|
||||
|
||||
viewLogger.setLastViewLogged( false );
|
||||
viewLogger.unview();
|
||||
|
||||
assert.ok( !logger.log.called, 'action logger not called' );
|
||||
assert.strictEqual( logger.log.called, false, 'action logger not called' );
|
||||
|
||||
viewLogger.setLastViewLogged( true );
|
||||
viewLogger.unview();
|
||||
|
||||
assert.ok( logger.log.calledOnce, 'action logger called' );
|
||||
assert.strictEqual( logger.log.calledOnce, true, 'action logger called' );
|
||||
|
||||
viewLogger.unview();
|
||||
|
||||
assert.ok( logger.log.calledOnce, 'action logger not called again' );
|
||||
assert.strictEqual( logger.log.calledOnce, true, 'action logger not called again' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'focus and blur', function ( assert ) {
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
assert.ok( generatedHtml.match( titleText ), 'Title appears in generated HTML.' );
|
||||
assert.ok( generatedHtml.match( filePageUrl ), 'Page url appears in generated HTML.' );
|
||||
assert.ok( generatedHtml.match( thumbUrl ), 'Thumbnail url appears in generated HTML' );
|
||||
assert.ok( !generatedHtml.match( 'Public License' ), 'License should not appear in generated HTML' );
|
||||
assert.notOk( generatedHtml.match( 'Public License' ), 'License should not appear in generated HTML' );
|
||||
assert.ok( generatedHtml.match( 'Homer' ), 'Author appears in generated HTML' );
|
||||
assert.ok( generatedHtml.match( 'Iliad' ), 'Source appears in generated HTML' );
|
||||
assert.ok( generatedHtml.match( width ), 'Width appears in generated HTML' );
|
||||
|
@ -141,8 +141,8 @@
|
|||
assert.ok( generatedHtml.match( filePageUrl ), 'Page url appears in generated HTML.' );
|
||||
assert.ok( generatedHtml.match( thumbUrl ), 'Thumbnail url appears in generated HTML' );
|
||||
assert.ok( generatedHtml.match( 'Public License' ), 'License appears in generated HTML' );
|
||||
assert.ok( !generatedHtml.match( 'Homer' ), 'Author should not appear in generated HTML' );
|
||||
assert.ok( !generatedHtml.match( 'Iliad' ), 'Source should not appear in generated HTML' );
|
||||
assert.notOk( generatedHtml.match( 'Homer' ), 'Author should not appear in generated HTML' );
|
||||
assert.notOk( generatedHtml.match( 'Iliad' ), 'Source should not appear in generated HTML' );
|
||||
assert.ok( generatedHtml.match( width ), 'Width appears in generated HTML' );
|
||||
assert.ok( generatedHtml.match( height ), 'Height appears in generated HTML' );
|
||||
assert.ok( generatedHtml.includes( filePageShortUrl ), 'Short URL appears in generated HTML' );
|
||||
|
@ -155,9 +155,9 @@
|
|||
assert.ok( generatedHtml.match( titleText ), 'Title appears in generated HTML.' );
|
||||
assert.ok( generatedHtml.match( filePageUrl ), 'Page url appears in generated HTML.' );
|
||||
assert.ok( generatedHtml.match( thumbUrl ), 'Thumbnail url appears in generated HTML' );
|
||||
assert.ok( !generatedHtml.match( 'Public License' ), 'License should not appear in generated HTML' );
|
||||
assert.ok( !generatedHtml.match( 'Homer' ), 'Author should not appear in generated HTML' );
|
||||
assert.ok( !generatedHtml.match( 'Iliad' ), 'Source should not appear in generated HTML' );
|
||||
assert.notOk( generatedHtml.match( 'Public License' ), 'License should not appear in generated HTML' );
|
||||
assert.notOk( generatedHtml.match( 'Homer' ), 'Author should not appear in generated HTML' );
|
||||
assert.notOk( generatedHtml.match( 'Iliad' ), 'Source should not appear in generated HTML' );
|
||||
assert.ok( generatedHtml.match( width ), 'Width appears in generated HTML' );
|
||||
assert.ok( generatedHtml.match( height ), 'Height appears in generated HTML' );
|
||||
assert.ok( generatedHtml.includes( filePageShortUrl ), 'Short URL appears in generated HTML' );
|
||||
|
|
|
@ -80,13 +80,13 @@
|
|||
utils.filterInvisible( $invisibleChildWithVisibleSiblings );
|
||||
|
||||
assert.ok( $visibleChild.has( 'span' ).length, 'visible child is not filtered' );
|
||||
assert.ok( !$invisibleChild.has( 'span' ).length, 'invisible child is filtered' );
|
||||
assert.notOk( $invisibleChild.has( 'span' ).length, 'invisible child is filtered' );
|
||||
assert.ok( $invisibleChildInVisibleChild.has( 'span' ).length, 'visible child is not filtered...' );
|
||||
assert.ok( !$invisibleChildInVisibleChild.has( 'abbr' ).length, '... but its invisible child is' );
|
||||
assert.ok( !$visibleChildInInvisibleChild.has( 'span' ).length, 'invisible child is filtered...' );
|
||||
assert.ok( !$visibleChildInInvisibleChild.has( 'abbr' ).length, '...and its children too' );
|
||||
assert.notOk( $invisibleChildInVisibleChild.has( 'abbr' ).length, '... but its invisible child is' );
|
||||
assert.notOk( $visibleChildInInvisibleChild.has( 'span' ).length, 'invisible child is filtered...' );
|
||||
assert.notOk( $visibleChildInInvisibleChild.has( 'abbr' ).length, '...and its children too' );
|
||||
assert.ok( $visibleChild.has( 'span' ).length, 'visible child is not filtered' );
|
||||
assert.ok( !$invisibleChildWithVisibleSiblings.has( 'abbr' ).length, 'invisible sibling is filtered...' );
|
||||
assert.notOk( $invisibleChildWithVisibleSiblings.has( 'abbr' ).length, 'invisible sibling is filtered...' );
|
||||
assert.ok( $invisibleChildWithVisibleSiblings.has( 'span' ).length, '...but its visible siblings are not' );
|
||||
assert.ok( $invisibleChildWithVisibleSiblings.has( 'b' ).length, '...but its visible siblings are not' );
|
||||
} );
|
||||
|
@ -106,12 +106,12 @@
|
|||
utils.whitelistHtml( $siblings, 'a' );
|
||||
|
||||
assert.ok( $whitelisted.has( 'a' ).length, 'Whitelisted elements are kept.' );
|
||||
assert.ok( !$nonWhitelisted.has( 'span' ).length, 'Non-whitelisted elements are removed.' );
|
||||
assert.notOk( $nonWhitelisted.has( 'span' ).length, 'Non-whitelisted elements are removed.' );
|
||||
assert.ok( $nonWhitelistedInWhitelisted.has( 'a' ).length, 'Whitelisted parents are kept.' );
|
||||
assert.ok( !$nonWhitelistedInWhitelisted.has( 'span' ).length, 'Non-whitelisted children are removed.' );
|
||||
assert.ok( !$whitelistedInNonWhitelisted.has( 'span' ).length, 'Non-whitelisted parents are removed.' );
|
||||
assert.notOk( $nonWhitelistedInWhitelisted.has( 'span' ).length, 'Non-whitelisted children are removed.' );
|
||||
assert.notOk( $whitelistedInNonWhitelisted.has( 'span' ).length, 'Non-whitelisted parents are removed.' );
|
||||
assert.ok( $whitelistedInNonWhitelisted.has( 'a' ).length, 'Whitelisted children are kept.' );
|
||||
assert.ok( !$siblings.has( 'span' ).length, 'Non-whitelisted siblings are removed.' );
|
||||
assert.notOk( $siblings.has( 'span' ).length, 'Non-whitelisted siblings are removed.' );
|
||||
assert.ok( $siblings.has( 'a' ).length, 'Whitelisted siblings are kept.' );
|
||||
} );
|
||||
|
||||
|
@ -176,9 +176,9 @@
|
|||
QUnit.test( 'isJQueryOrHTMLElement()', function ( assert ) {
|
||||
var utils = new mw.mmv.HtmlUtils();
|
||||
|
||||
assert.ok( utils.isJQueryOrHTMLElement( $( '<span>' ) ), 'Recognizes jQuery objects correctly' );
|
||||
assert.ok( utils.isJQueryOrHTMLElement( $( '<span>' ).get( 0 ) ), 'Recognizes HTMLElements correctly' );
|
||||
assert.ok( !utils.isJQueryOrHTMLElement( '<span></span>' ), 'Recognizes jQuery objects correctly' );
|
||||
assert.strictEqual( utils.isJQueryOrHTMLElement( $( '<span>' ) ), true, 'Recognizes jQuery objects correctly' );
|
||||
assert.strictEqual( utils.isJQueryOrHTMLElement( $( '<span>' ).get( 0 ) ), true, 'Recognizes HTMLElements correctly' );
|
||||
assert.strictEqual( utils.isJQueryOrHTMLElement( '<span></span>' ), false, 'Doesn\'t recognize HTML string' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'makeLinkText()', function ( assert ) {
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
} );
|
||||
|
||||
return mw.mmv.testHelpers.waitForAsync().then( function () {
|
||||
assert.ok( callCount === 1, 'Viewer should be loaded once' );
|
||||
assert.strictEqual( callCount, 1, 'Viewer should be loaded once' );
|
||||
bootstrap.cleanupEventHandlers();
|
||||
window.location.hash = '';
|
||||
} );
|
||||
|
@ -112,8 +112,8 @@
|
|||
this.sandbox.stub( bootstrap, 'cleanupOverlay' );
|
||||
|
||||
bootstrap.loadViewer( true ).fail( function ( message ) {
|
||||
assert.ok( bootstrap.setupOverlay.called, 'Overlay was set up' );
|
||||
assert.ok( bootstrap.cleanupOverlay.called, 'Overlay was cleaned up' );
|
||||
assert.strictEqual( bootstrap.setupOverlay.called, true, 'Overlay was set up' );
|
||||
assert.strictEqual( bootstrap.cleanupOverlay.called, true, 'Overlay was cleaned up' );
|
||||
assert.strictEqual( message, errorMessage, 'promise is rejected with the error message when loading fails' );
|
||||
done();
|
||||
} );
|
||||
|
@ -142,7 +142,7 @@
|
|||
event = new $.Event( 'click', { button: 0, which: 1 } );
|
||||
returnValue = bootstrap.click( {}, event, mw.Title.newFromText( 'Foo' ) );
|
||||
clock.tick( 10 );
|
||||
assert.ok( !event.isDefaultPrevented(), 'Click after loading failure is not caught' );
|
||||
assert.strictEqual( event.isDefaultPrevented(), false, 'Click after loading failure is not caught' );
|
||||
assert.notStrictEqual( returnValue, false, 'Click after loading failure is not caught' );
|
||||
|
||||
clock.restore();
|
||||
|
@ -256,7 +256,7 @@
|
|||
link.trigger( { type: 'click', which: 1 } );
|
||||
clock.tick( 10 );
|
||||
|
||||
assert.ok( !viewer.loadImageByTitle.called, 'Image should not be loaded' );
|
||||
assert.strictEqual( viewer.loadImageByTitle.called, false, 'Image should not be loaded' );
|
||||
|
||||
clock.restore();
|
||||
} );
|
||||
|
@ -427,7 +427,7 @@
|
|||
|
||||
bootstrap.hash();
|
||||
|
||||
assert.ok( !bootstrap.setupOverlay.called, 'Overlay is not set up' );
|
||||
assert.strictEqual( bootstrap.setupOverlay.called, false, 'Overlay is not set up' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'internalHashChange', function ( assert ) {
|
||||
|
@ -529,13 +529,13 @@
|
|||
clock.tick( bootstrap.hoverWaitDuration - 50 );
|
||||
$div.trigger( 'mouseleave' );
|
||||
|
||||
assert.ok( !mw.loader.load.called, 'Dependencies should not be preloaded if the thumb is not hovered long enough' );
|
||||
assert.strictEqual( mw.loader.load.called, false, 'Dependencies should not be preloaded if the thumb is not hovered long enough' );
|
||||
|
||||
$div.trigger( 'mouseenter' );
|
||||
clock.tick( bootstrap.hoverWaitDuration + 50 );
|
||||
$div.trigger( 'mouseleave' );
|
||||
|
||||
assert.ok( mw.loader.load.called, 'Dependencies should be preloaded if the thumb is hovered long enough' );
|
||||
assert.strictEqual( mw.loader.load.called, true, 'Dependencies should be preloaded if the thumb is hovered long enough' );
|
||||
|
||||
clock.restore();
|
||||
} );
|
||||
|
@ -545,7 +545,7 @@
|
|||
$thumb = $( '<img>' ).appendTo( $container ),
|
||||
bootstrap = createBootstrap();
|
||||
|
||||
assert.ok( bootstrap.isAllowedThumb( $thumb ), 'Normal image in a div is allowed.' );
|
||||
assert.strictEqual( bootstrap.isAllowedThumb( $thumb ), true, 'Normal image in a div is allowed.' );
|
||||
|
||||
$container.addClass( 'metadata' );
|
||||
assert.strictEqual( bootstrap.isAllowedThumb( $thumb ), false, 'Image in a metadata container is disallowed.' );
|
||||
|
|
|
@ -168,8 +168,8 @@
|
|||
viewer.ui = lightbox;
|
||||
viewer.ui = lightbox;
|
||||
|
||||
assert.ok( !lightbox.isFullscreen, 'Lightbox knows that it\'s not in fullscreen mode' );
|
||||
assert.ok( lightbox.panel.$imageMetadata.is( ':visible' ), 'Image metadata is visible' );
|
||||
assert.strictEqual( lightbox.isFullscreen, false, 'Lightbox knows that it\'s not in fullscreen mode' );
|
||||
assert.strictEqual( lightbox.panel.$imageMetadata.is( ':visible' ), true, 'Image metadata is visible' );
|
||||
|
||||
lightbox.buttons.fadeOut = function () {
|
||||
assert.ok( true, 'Opening fullscreen triggers a fadeout' );
|
||||
|
@ -214,7 +214,7 @@
|
|||
panelBottom = $( '.mw-mmv-post-image' ).position().top + $( '.mw-mmv-post-image' ).height();
|
||||
|
||||
assert.ok( panelBottom > $( window ).height(), 'Image metadata extends beyond the viewport' );
|
||||
assert.ok( !lightbox.isFullscreen, 'Lightbox knows that it\'s not in fullscreen mode' );
|
||||
assert.strictEqual( lightbox.isFullscreen, false, 'Lightbox knows that it\'s not in fullscreen mode' );
|
||||
|
||||
// Unattach lightbox from document
|
||||
lightbox.unattach();
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
viewer.ui = ui;
|
||||
viewer.close();
|
||||
|
||||
assert.ok( !viewer.isOpen, 'Viewer is closed' );
|
||||
assert.strictEqual( viewer.isOpen, false, 'Viewer is closed' );
|
||||
|
||||
viewer.isOpen = true;
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
|||
|
||||
// Verify that mmv doesn't reset a foreign hash
|
||||
assert.strictEqual( window.location.hash, '#Foo', 'Foreign hash remains intact' );
|
||||
assert.ok( !viewer.isOpen, 'Viewer is closed' );
|
||||
assert.strictEqual( viewer.isOpen, false, 'Viewer is closed' );
|
||||
|
||||
ui.unattach = function () {
|
||||
assert.ok( false, 'Lightbox was not unattached' );
|
||||
|
@ -156,19 +156,19 @@
|
|||
// progress handlers
|
||||
viewer.loadImage( fakeImage, new Image() );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.jumpTo.lastCall.calledWith( 0 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.jumpTo.lastCall.calledWith( 0 ), true,
|
||||
'Percentage correctly reset by loadImage' );
|
||||
assert.ok( viewer.ui.panel.progressBar.animateTo.firstCall.calledWith( 5 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.animateTo.firstCall.calledWith( 5 ), true,
|
||||
'Percentage correctly animated to 5 by loadImage' );
|
||||
|
||||
imageDeferred.notify( 'response', 45 );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.animateTo.secondCall.calledWith( 45 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.animateTo.secondCall.calledWith( 45 ), true,
|
||||
'Percentage correctly funneled to panel UI' );
|
||||
|
||||
imageDeferred.resolve( {}, {} );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.animateTo.thirdCall.calledWith( 100 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.animateTo.thirdCall.calledWith( 100 ), true,
|
||||
'Percentage correctly funneled to panel UI' );
|
||||
|
||||
clock.restore();
|
||||
|
@ -234,30 +234,30 @@
|
|||
viewer.imageProvider.get = this.sandbox.stub().returns( firstImageDeferred );
|
||||
viewer.loadImage( firstImage, new Image() );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.jumpTo.getCall( 0 ).calledWith( 0 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.jumpTo.getCall( 0 ).calledWith( 0 ), true,
|
||||
'Percentage correctly reset for new first image' );
|
||||
assert.ok( viewer.ui.panel.progressBar.animateTo.getCall( 0 ).calledWith( 5 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.animateTo.getCall( 0 ).calledWith( 5 ), true,
|
||||
'Percentage correctly animated to 5 for first new image' );
|
||||
|
||||
// progress on active image
|
||||
firstImageDeferred.notify( 'response', 20 );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.animateTo.getCall( 1 ).calledWith( 20 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.animateTo.getCall( 1 ).calledWith( 20 ), true,
|
||||
'Percentage correctly animated when active image is loading' );
|
||||
|
||||
// change to another image
|
||||
viewer.imageProvider.get = this.sandbox.stub().returns( secondImageDeferred );
|
||||
viewer.loadImage( secondImage, new Image() );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.jumpTo.getCall( 1 ).calledWith( 0 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.jumpTo.getCall( 1 ).calledWith( 0 ), true,
|
||||
'Percentage correctly reset for second new image' );
|
||||
assert.ok( viewer.ui.panel.progressBar.animateTo.getCall( 2 ).calledWith( 5 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.animateTo.getCall( 2 ).calledWith( 5 ), true,
|
||||
'Percentage correctly animated to 5 for second new image' );
|
||||
|
||||
// progress on active image
|
||||
secondImageDeferred.notify( 'response', 30 );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.animateTo.getCall( 3 ).calledWith( 30 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.animateTo.getCall( 3 ).calledWith( 30 ), true,
|
||||
'Percentage correctly animated when active image is loading' );
|
||||
|
||||
// progress on inactive image
|
||||
|
@ -269,26 +269,26 @@
|
|||
// progress on active image
|
||||
secondImageDeferred.notify( 'response', 50 );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.animateTo.getCall( 4 ).calledWith( 50 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.animateTo.getCall( 4 ).calledWith( 50 ), true,
|
||||
'Percentage correctly ignored inactive image & only animated when active image is loading' );
|
||||
|
||||
// change back to first image
|
||||
viewer.imageProvider.get = this.sandbox.stub().returns( firstImageDeferred );
|
||||
viewer.loadImage( firstImage, new Image() );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.jumpTo.getCall( 2 ).calledWith( 40 ),
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.jumpTo.getCall( 2 ).calledWith( 40 ), true,
|
||||
'Percentage jumps to right value when changing images' );
|
||||
|
||||
secondImageDeferred.resolve( {}, {} );
|
||||
clock.tick( 10 );
|
||||
assert.ok( !viewer.ui.panel.progressBar.hide.called,
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.hide.called, false,
|
||||
'Progress bar not hidden when something finishes in the background' );
|
||||
|
||||
// change back to second image, which has finished loading
|
||||
viewer.imageProvider.get = this.sandbox.stub().returns( secondImageDeferred );
|
||||
viewer.loadImage( secondImage, new Image() );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.ui.panel.progressBar.hide.called,
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.hide.called, true,
|
||||
'Progress bar hidden when switching to finished image' );
|
||||
|
||||
clock.restore();
|
||||
|
@ -302,16 +302,16 @@
|
|||
// animation would keep running, conflict with other tests
|
||||
this.sandbox.stub( $.fn, 'animate' ).returnsThis();
|
||||
|
||||
assert.ok( !viewer.realThumbnailShown, 'Real thumbnail state is correct' );
|
||||
assert.ok( !viewer.blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( viewer.realThumbnailShown, false, 'Real thumbnail state is correct' );
|
||||
assert.strictEqual( viewer.blurredThumbnailShown, false, 'Placeholder state is correct' );
|
||||
|
||||
viewer.realThumbnailShown = true;
|
||||
viewer.blurredThumbnailShown = true;
|
||||
|
||||
viewer.resetBlurredThumbnailStates();
|
||||
|
||||
assert.ok( !viewer.realThumbnailShown, 'Real thumbnail state is correct' );
|
||||
assert.ok( !viewer.blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( viewer.realThumbnailShown, false, 'Real thumbnail state is correct' );
|
||||
assert.strictEqual( viewer.blurredThumbnailShown, false, 'Placeholder state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Placeholder first, then real thumbnail', function ( assert ) {
|
||||
|
@ -327,13 +327,13 @@
|
|||
|
||||
viewer.displayPlaceholderThumbnail( { originalWidth: 100, originalHeight: 100 }, undefined, undefined );
|
||||
|
||||
assert.ok( viewer.blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.ok( !viewer.realThumbnailShown, 'Real thumbnail state is correct' );
|
||||
assert.strictEqual( viewer.blurredThumbnailShown, true, 'Placeholder state is correct' );
|
||||
assert.strictEqual( viewer.realThumbnailShown, false, 'Real thumbnail state is correct' );
|
||||
|
||||
viewer.displayRealThumbnail( { url: undefined } );
|
||||
|
||||
assert.ok( viewer.realThumbnailShown, 'Real thumbnail state is correct' );
|
||||
assert.ok( viewer.blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( viewer.realThumbnailShown, true, 'Real thumbnail state is correct' );
|
||||
assert.strictEqual( viewer.blurredThumbnailShown, true, 'Placeholder state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Placeholder first, then real thumbnail - missing size', function ( assert ) {
|
||||
|
@ -350,13 +350,13 @@
|
|||
|
||||
viewer.displayPlaceholderThumbnail( { index: 1 }, undefined, undefined );
|
||||
|
||||
assert.ok( viewer.blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.ok( !viewer.realThumbnailShown, 'Real thumbnail state is correct' );
|
||||
assert.strictEqual( viewer.blurredThumbnailShown, true, 'Placeholder state is correct' );
|
||||
assert.strictEqual( viewer.realThumbnailShown, false, 'Real thumbnail state is correct' );
|
||||
|
||||
viewer.displayRealThumbnail( { url: undefined } );
|
||||
|
||||
assert.ok( viewer.realThumbnailShown, 'Real thumbnail state is correct' );
|
||||
assert.ok( viewer.blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( viewer.realThumbnailShown, true, 'Real thumbnail state is correct' );
|
||||
assert.strictEqual( viewer.blurredThumbnailShown, true, 'Placeholder state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Real thumbnail first, then placeholder', function ( assert ) {
|
||||
|
@ -372,13 +372,13 @@
|
|||
|
||||
viewer.displayRealThumbnail( { url: undefined } );
|
||||
|
||||
assert.ok( viewer.realThumbnailShown, 'Real thumbnail state is correct' );
|
||||
assert.ok( !viewer.blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( viewer.realThumbnailShown, true, 'Real thumbnail state is correct' );
|
||||
assert.strictEqual( viewer.blurredThumbnailShown, false, 'Placeholder state is correct' );
|
||||
|
||||
viewer.displayPlaceholderThumbnail( {}, undefined, undefined );
|
||||
|
||||
assert.ok( viewer.realThumbnailShown, 'Real thumbnail state is correct' );
|
||||
assert.ok( !viewer.blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( viewer.realThumbnailShown, true, 'Real thumbnail state is correct' );
|
||||
assert.strictEqual( viewer.blurredThumbnailShown, false, 'Placeholder state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'displayRealThumbnail', function ( assert ) {
|
||||
|
@ -393,11 +393,11 @@
|
|||
|
||||
// Should not result in an unblurWithAnimation animation (image cache from cache)
|
||||
viewer.displayRealThumbnail( { url: undefined }, undefined, undefined, 5 );
|
||||
assert.ok( !viewer.ui.canvas.unblurWithAnimation.called, 'There should not be an unblurWithAnimation animation' );
|
||||
assert.strictEqual( viewer.ui.canvas.unblurWithAnimation.called, false, 'There should not be an unblurWithAnimation animation' );
|
||||
|
||||
// Should result in an unblurWithAnimation (image didn't come from cache)
|
||||
viewer.displayRealThumbnail( { url: undefined }, undefined, undefined, 1000 );
|
||||
assert.ok( viewer.ui.canvas.unblurWithAnimation.called, 'There should be an unblurWithAnimation animation' );
|
||||
assert.strictEqual( viewer.ui.canvas.unblurWithAnimation.called, true, 'There should be an unblurWithAnimation animation' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'New image loaded while another one is loading', function ( assert ) {
|
||||
|
@ -453,8 +453,8 @@
|
|||
viewer.fetchSizeIndependentLightboxInfo.returns( firstLigthboxInfoDeferred.promise() );
|
||||
viewer.loadImage( firstImage, new Image() );
|
||||
clock.tick( 10 );
|
||||
assert.ok( !viewer.animateMetadataDivOnce.called, 'Metadata of the first image should not be animated' );
|
||||
assert.ok( !viewer.ui.panel.setImageInfo.called, 'Metadata of the first image should not be shown' );
|
||||
assert.strictEqual( viewer.animateMetadataDivOnce.called, false, 'Metadata of the first image should not be animated' );
|
||||
assert.strictEqual( viewer.ui.panel.setImageInfo.called, false, 'Metadata of the first image should not be shown' );
|
||||
|
||||
viewer.imageProvider.get.returns( secondImageDeferred.promise() );
|
||||
viewer.fetchSizeIndependentLightboxInfo.returns( secondLigthboxInfoDeferred.promise() );
|
||||
|
@ -464,18 +464,18 @@
|
|||
viewer.ui.panel.progressBar.animateTo.reset();
|
||||
firstImageDeferred.notify( undefined, 45 );
|
||||
clock.tick( 10 );
|
||||
assert.ok( !viewer.ui.panel.progressBar.animateTo.reset.called, 'Progress of the first image should not be shown' );
|
||||
assert.strictEqual( viewer.ui.panel.progressBar.animateTo.reset.called, undefined, 'Progress of the first image should not be shown' );
|
||||
|
||||
firstImageDeferred.resolve( {}, {} );
|
||||
firstLigthboxInfoDeferred.resolve( {} );
|
||||
clock.tick( 10 );
|
||||
assert.ok( !viewer.displayRealThumbnail.called, 'The first image being done loading should have no effect' );
|
||||
assert.strictEqual( viewer.displayRealThumbnail.called, false, 'The first image being done loading should have no effect' );
|
||||
|
||||
viewer.displayRealThumbnail = this.sandbox.spy( function () { viewer.close(); } );
|
||||
secondImageDeferred.resolve( {}, {} );
|
||||
secondLigthboxInfoDeferred.resolve( {} );
|
||||
clock.tick( 10 );
|
||||
assert.ok( viewer.displayRealThumbnail.called, 'The second image being done loading should result in the image being shown' );
|
||||
assert.strictEqual( viewer.displayRealThumbnail.called, true, 'The second image being done loading should result in the image being shown' );
|
||||
|
||||
clock.restore();
|
||||
} );
|
||||
|
@ -606,10 +606,10 @@
|
|||
imageStub.returns( $.Deferred().resolve( image ) );
|
||||
promise = viewer.fetchThumbnail( file, width );
|
||||
clock.tick( 10 );
|
||||
assert.ok( !guessedThumbnailInfoStub.called, 'When we lack sample URL and original dimensions, GuessedThumbnailInfoProvider is not called' );
|
||||
assert.ok( thumbnailInfoStub.calledOnce, 'When we lack sample URL and original dimensions, ThumbnailInfoProvider is called once' );
|
||||
assert.ok( imageStub.calledOnce, 'When we lack sample URL and original dimensions, ImageProvider is called once' );
|
||||
assert.ok( imageStub.calledWith( 'apiURL' ), 'When we lack sample URL and original dimensions, ImageProvider is called with the API url' );
|
||||
assert.strictEqual( guessedThumbnailInfoStub.called, false, 'When we lack sample URL and original dimensions, GuessedThumbnailInfoProvider is not called' );
|
||||
assert.strictEqual( thumbnailInfoStub.calledOnce, true, 'When we lack sample URL and original dimensions, ThumbnailInfoProvider is called once' );
|
||||
assert.strictEqual( imageStub.calledOnce, true, 'When we lack sample URL and original dimensions, ImageProvider is called once' );
|
||||
assert.strictEqual( imageStub.calledWith( 'apiURL' ), true, 'When we lack sample URL and original dimensions, ImageProvider is called with the API url' );
|
||||
assert.strictEqual( promise.state(), 'resolved', 'When we lack sample URL and original dimensions, fetchThumbnail resolves' );
|
||||
|
||||
// When the guesser bails out, the classic provider should be used
|
||||
|
@ -619,10 +619,10 @@
|
|||
imageStub.returns( $.Deferred().resolve( image ) );
|
||||
promise = viewer.fetchThumbnail( file, width, sampleURL, originalWidth, originalHeight );
|
||||
clock.tick( 10 );
|
||||
assert.ok( guessedThumbnailInfoStub.calledOnce, 'When the guesser bails out, GuessedThumbnailInfoProvider is called once' );
|
||||
assert.ok( thumbnailInfoStub.calledOnce, 'When the guesser bails out, ThumbnailInfoProvider is called once' );
|
||||
assert.ok( imageStub.calledOnce, 'When the guesser bails out, ImageProvider is called once' );
|
||||
assert.ok( imageStub.calledWith( 'apiURL' ), 'When the guesser bails out, ImageProvider is called with the API url' );
|
||||
assert.strictEqual( guessedThumbnailInfoStub.calledOnce, true, 'When the guesser bails out, GuessedThumbnailInfoProvider is called once' );
|
||||
assert.strictEqual( thumbnailInfoStub.calledOnce, true, 'When the guesser bails out, ThumbnailInfoProvider is called once' );
|
||||
assert.strictEqual( imageStub.calledOnce, true, 'When the guesser bails out, ImageProvider is called once' );
|
||||
assert.strictEqual( imageStub.calledWith( 'apiURL' ), true, 'When the guesser bails out, ImageProvider is called with the API url' );
|
||||
assert.strictEqual( promise.state(), 'resolved', 'When the guesser bails out, fetchThumbnail resolves' );
|
||||
|
||||
// When the guesser returns an URL, that should be used
|
||||
|
@ -632,10 +632,10 @@
|
|||
imageStub.returns( $.Deferred().resolve( image ) );
|
||||
promise = viewer.fetchThumbnail( file, width, sampleURL, originalWidth, originalHeight );
|
||||
clock.tick( 10 );
|
||||
assert.ok( guessedThumbnailInfoStub.calledOnce, 'When the guesser returns an URL, GuessedThumbnailInfoProvider is called once' );
|
||||
assert.ok( !thumbnailInfoStub.called, 'When the guesser returns an URL, ThumbnailInfoProvider is not called' );
|
||||
assert.ok( imageStub.calledOnce, 'When the guesser returns an URL, ImageProvider is called once' );
|
||||
assert.ok( imageStub.calledWith( 'guessedURL' ), 'When the guesser returns an URL, ImageProvider is called with the guessed url' );
|
||||
assert.strictEqual( guessedThumbnailInfoStub.calledOnce, true, 'When the guesser returns an URL, GuessedThumbnailInfoProvider is called once' );
|
||||
assert.strictEqual( thumbnailInfoStub.called, false, 'When the guesser returns an URL, ThumbnailInfoProvider is not called' );
|
||||
assert.strictEqual( imageStub.calledOnce, true, 'When the guesser returns an URL, ImageProvider is called once' );
|
||||
assert.strictEqual( imageStub.calledWith( 'guessedURL' ), true, 'When the guesser returns an URL, ImageProvider is called with the guessed url' );
|
||||
assert.strictEqual( promise.state(), 'resolved', 'When the guesser returns an URL, fetchThumbnail resolves' );
|
||||
|
||||
// When the guesser returns an URL, but that returns 404, image loading should be retried with the classic provider
|
||||
|
@ -646,11 +646,11 @@
|
|||
imageStub.withArgs( 'apiURL' ).returns( $.Deferred().resolve( image ) );
|
||||
promise = viewer.fetchThumbnail( file, width, sampleURL, originalWidth, originalHeight );
|
||||
clock.tick( 10 );
|
||||
assert.ok( guessedThumbnailInfoStub.calledOnce, 'When the guesser returns an URL, but that returns 404, GuessedThumbnailInfoProvider is called once' );
|
||||
assert.ok( thumbnailInfoStub.calledOnce, 'When the guesser returns an URL, but that returns 404, ThumbnailInfoProvider is called once' );
|
||||
assert.ok( imageStub.calledTwice, 'When the guesser returns an URL, but that returns 404, ImageProvider is called twice' );
|
||||
assert.ok( imageStub.getCall( 0 ).calledWith( 'guessedURL' ), 'When the guesser returns an URL, but that returns 404, ImageProvider is called first with the guessed url' );
|
||||
assert.ok( imageStub.getCall( 1 ).calledWith( 'apiURL' ), 'When the guesser returns an URL, but that returns 404, ImageProvider is called second with the guessed url' );
|
||||
assert.strictEqual( guessedThumbnailInfoStub.calledOnce, true, 'When the guesser returns an URL, but that returns 404, GuessedThumbnailInfoProvider is called once' );
|
||||
assert.strictEqual( thumbnailInfoStub.calledOnce, true, 'When the guesser returns an URL, but that returns 404, ThumbnailInfoProvider is called once' );
|
||||
assert.strictEqual( imageStub.calledTwice, true, 'When the guesser returns an URL, but that returns 404, ImageProvider is called twice' );
|
||||
assert.strictEqual( imageStub.getCall( 0 ).calledWith( 'guessedURL' ), true, 'When the guesser returns an URL, but that returns 404, ImageProvider is called first with the guessed url' );
|
||||
assert.strictEqual( imageStub.getCall( 1 ).calledWith( 'apiURL' ), true, 'When the guesser returns an URL, but that returns 404, ImageProvider is called second with the guessed url' );
|
||||
assert.strictEqual( promise.state(), 'resolved', 'When the guesser returns an URL, but that returns 404, fetchThumbnail resolves' );
|
||||
|
||||
// When even the retry fails, fetchThumbnail() should reject
|
||||
|
@ -661,11 +661,11 @@
|
|||
imageStub.withArgs( 'apiURL' ).returns( $.Deferred().reject() );
|
||||
promise = viewer.fetchThumbnail( file, width, sampleURL, originalWidth, originalHeight );
|
||||
clock.tick( 10 );
|
||||
assert.ok( guessedThumbnailInfoStub.calledOnce, 'When even the retry fails, GuessedThumbnailInfoProvider is called once' );
|
||||
assert.ok( thumbnailInfoStub.calledOnce, 'When even the retry fails, ThumbnailInfoProvider is called once' );
|
||||
assert.ok( imageStub.calledTwice, 'When even the retry fails, ImageProvider is called twice' );
|
||||
assert.ok( imageStub.getCall( 0 ).calledWith( 'guessedURL' ), 'When even the retry fails, ImageProvider is called first with the guessed url' );
|
||||
assert.ok( imageStub.getCall( 1 ).calledWith( 'apiURL' ), 'When even the retry fails, ImageProvider is called second with the guessed url' );
|
||||
assert.strictEqual( guessedThumbnailInfoStub.calledOnce, true, 'When even the retry fails, GuessedThumbnailInfoProvider is called once' );
|
||||
assert.strictEqual( thumbnailInfoStub.calledOnce, true, 'When even the retry fails, ThumbnailInfoProvider is called once' );
|
||||
assert.strictEqual( imageStub.calledTwice, true, 'When even the retry fails, ImageProvider is called twice' );
|
||||
assert.strictEqual( imageStub.getCall( 0 ).calledWith( 'guessedURL' ), true, 'When even the retry fails, ImageProvider is called first with the guessed url' );
|
||||
assert.strictEqual( imageStub.getCall( 1 ).calledWith( 'apiURL' ), true, 'When even the retry fails, ImageProvider is called second with the guessed url' );
|
||||
assert.strictEqual( promise.state(), 'rejected', 'When even the retry fails, fetchThumbnail rejects' );
|
||||
|
||||
useThumbnailGuessing = false;
|
||||
|
@ -677,10 +677,10 @@
|
|||
imageStub.returns( $.Deferred().resolve( image ) );
|
||||
promise = viewer.fetchThumbnail( file, width );
|
||||
clock.tick( 10 );
|
||||
assert.ok( !guessedThumbnailInfoStub.called, 'When guessing is disabled, GuessedThumbnailInfoProvider is not called' );
|
||||
assert.ok( thumbnailInfoStub.calledOnce, 'When guessing is disabled, ThumbnailInfoProvider is called once' );
|
||||
assert.ok( imageStub.calledOnce, 'When guessing is disabled, ImageProvider is called once' );
|
||||
assert.ok( imageStub.calledWith( 'apiURL' ), 'When guessing is disabled, ImageProvider is called with the API url' );
|
||||
assert.strictEqual( guessedThumbnailInfoStub.called, false, 'When guessing is disabled, GuessedThumbnailInfoProvider is not called' );
|
||||
assert.strictEqual( thumbnailInfoStub.calledOnce, true, 'When guessing is disabled, ThumbnailInfoProvider is called once' );
|
||||
assert.strictEqual( imageStub.calledOnce, true, 'When guessing is disabled, ImageProvider is called once' );
|
||||
assert.strictEqual( imageStub.calledWith( 'apiURL' ), true, 'When guessing is disabled, ImageProvider is called with the API url' );
|
||||
assert.strictEqual( promise.state(), 'resolved', 'When guessing is disabled, fetchThumbnail resolves' );
|
||||
|
||||
clock.restore();
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
license = new mw.mmv.model.License( shortName );
|
||||
assert.ok( license, 'License created successfully' );
|
||||
assert.strictEqual( license.shortName, shortName, 'License has correct short name' );
|
||||
assert.ok( !license.internalName, 'License has no internal name' );
|
||||
assert.ok( !license.longName, 'License has no long name' );
|
||||
assert.ok( !license.deedUrl, 'License has no deed URL' );
|
||||
assert.notOk( license.internalName, 'License has no internal name' );
|
||||
assert.notOk( license.longName, 'License has no long name' );
|
||||
assert.notOk( license.deedUrl, 'License has no deed URL' );
|
||||
|
||||
license = new mw.mmv.model.License( shortName, internalName, longName, url );
|
||||
assert.ok( license, 'License created successfully' );
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
|
||||
api.get = this.sandbox.stub();
|
||||
apiProvider.apiGetWithMaxAge( {} );
|
||||
assert.ok( !( 'maxage' in api.get.getCall( 0 ).args[ 0 ] ), 'maxage is not set by default' );
|
||||
assert.ok( !( 'smaxage' in api.get.getCall( 0 ).args[ 0 ] ), 'smaxage is not set by default' );
|
||||
assert.strictEqual( 'maxage' in api.get.getCall( 0 ).args[ 0 ], false, 'maxage is not set by default' );
|
||||
assert.strictEqual( 'smaxage' in api.get.getCall( 0 ).args[ 0 ], false, 'smaxage is not set by default' );
|
||||
|
||||
options = { maxage: 123 };
|
||||
apiProvider = new mw.mmv.provider.Api( api, options );
|
||||
|
@ -53,8 +53,8 @@
|
|||
|
||||
api.get = this.sandbox.stub();
|
||||
apiProvider.apiGetWithMaxAge( {}, null, null );
|
||||
assert.ok( !( 'maxage' in api.get.getCall( 0 ).args[ 0 ] ), 'maxage can be overridden to unset' );
|
||||
assert.ok( !( 'smaxage' in api.get.getCall( 0 ).args[ 0 ] ), 'smaxage can be overridden to unset' );
|
||||
assert.strictEqual( 'maxage' in api.get.getCall( 0 ).args[ 0 ], false, 'maxage can be overridden to unset' );
|
||||
assert.strictEqual( 'smaxage' in api.get.getCall( 0 ).args[ 0 ], false, 'smaxage can be overridden to unset' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getCachedPromise success', function ( assert ) {
|
||||
|
@ -70,7 +70,7 @@
|
|||
|
||||
promiseSource = function ( result ) {
|
||||
return function () {
|
||||
assert.ok( !promiseShouldBeCached, 'promise was not cached' );
|
||||
assert.strictEqual( promiseShouldBeCached, false, 'promise was not cached' );
|
||||
return $.Deferred().resolve( result );
|
||||
};
|
||||
};
|
||||
|
@ -104,7 +104,7 @@
|
|||
|
||||
promiseSource = function ( result ) {
|
||||
return function () {
|
||||
assert.ok( !promiseShouldBeCached, 'promise was not cached' );
|
||||
assert.strictEqual( promiseShouldBeCached, false, 'promise was not cached' );
|
||||
return $.Deferred().reject( result );
|
||||
};
|
||||
};
|
||||
|
|
|
@ -108,24 +108,26 @@
|
|||
var provider = new mw.mmv.provider.GuessedThumbnailInfo(),
|
||||
file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
assert.ok( !provider.needsOriginal( file, 100, 1000 ), 'Thumbnail of an SVG smaller than the original size doesn\'t need original' );
|
||||
assert.ok( !provider.needsOriginal( file, 1000, 1000 ), 'Thumbnail of an SVG equal to the original size doesn\'t need original' );
|
||||
assert.ok( !provider.needsOriginal( file, 2000, 1000 ), 'Thumbnail of an SVG bigger than the original size doesn\'t need original' );
|
||||
assert.strictEqual( provider.needsOriginal( file, 100, 1000 ), false, 'Thumbnail of an SVG smaller than the original size doesn\'t need original' );
|
||||
assert.strictEqual( provider.needsOriginal( file, 1000, 1000 ), false, 'Thumbnail of an SVG equal to the original size doesn\'t need original' );
|
||||
assert.strictEqual( provider.needsOriginal( file, 2000, 1000 ), false, 'Thumbnail of an SVG bigger than the original size doesn\'t need original' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.png' );
|
||||
|
||||
assert.ok( !provider.needsOriginal( file, 100, 1000 ), 'Thumbnail of a PNG smaller than the original size doesn\'t need original' );
|
||||
assert.ok( provider.needsOriginal( file, 1000, 1000 ), 'Thumbnail of a PNG equal to the original size needs original' );
|
||||
assert.ok( provider.needsOriginal( file, 2000, 1000 ), 'Thumbnail of a PNG bigger than the original size needs original' );
|
||||
assert.strictEqual( provider.needsOriginal( file, 100, 1000 ), false, 'Thumbnail of a PNG smaller than the original size doesn\'t need original' );
|
||||
assert.strictEqual( provider.needsOriginal( file, 1000, 1000 ), true, 'Thumbnail of a PNG equal to the original size needs original' );
|
||||
assert.strictEqual( provider.needsOriginal( file, 2000, 1000 ), true, 'Thumbnail of a PNG bigger than the original size needs original' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'isFullSizeUrl()', function ( assert ) {
|
||||
var provider = new mw.mmv.provider.GuessedThumbnailInfo(),
|
||||
file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
assert.ok( !provider.isFullSizeUrl( 'http://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Copyleft.svg/300px-Copyleft.svg.png', file ),
|
||||
assert.strictEqual( provider.isFullSizeUrl( 'http://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Copyleft.svg/300px-Copyleft.svg.png', file ),
|
||||
false,
|
||||
'Thumbnail url recognized as not being full size' );
|
||||
assert.ok( provider.isFullSizeUrl( 'http://upload.wikimedia.org/wikipedia/commons/8/8b/Copyleft.svg', file ),
|
||||
assert.strictEqual( provider.isFullSizeUrl( 'http://upload.wikimedia.org/wikipedia/commons/8/8b/Copyleft.svg', file ),
|
||||
true,
|
||||
'Original url recognized as being full size' );
|
||||
} );
|
||||
|
||||
|
@ -155,54 +157,54 @@
|
|||
var provider = new mw.mmv.provider.GuessedThumbnailInfo(),
|
||||
file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
assert.ok( provider.canHaveLargerThumbnailThanOriginal( file ), 'SVG can have a larger thumbnail than the original' );
|
||||
assert.strictEqual( provider.canHaveLargerThumbnailThanOriginal( file ), true, 'SVG can have a larger thumbnail than the original' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.jpg' );
|
||||
|
||||
assert.ok( !provider.canHaveLargerThumbnailThanOriginal( file ), 'JPG can\'t have a larger thumbnail than the original' );
|
||||
assert.strictEqual( provider.canHaveLargerThumbnailThanOriginal( file ), false, 'JPG can\'t have a larger thumbnail than the original' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.png' );
|
||||
|
||||
assert.ok( !provider.canHaveLargerThumbnailThanOriginal( file ), 'PNG can\'t have a larger thumbnail than the original' );
|
||||
assert.strictEqual( provider.canHaveLargerThumbnailThanOriginal( file ), false, 'PNG can\'t have a larger thumbnail than the original' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.jpeg' );
|
||||
|
||||
assert.ok( !provider.canHaveLargerThumbnailThanOriginal( file ), 'JPEG can\'t have a larger thumbnail than the original' );
|
||||
assert.strictEqual( provider.canHaveLargerThumbnailThanOriginal( file ), false, 'JPEG can\'t have a larger thumbnail than the original' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.tiff' );
|
||||
|
||||
assert.ok( !provider.canHaveLargerThumbnailThanOriginal( file ), 'TIFF can\'t have a larger thumbnail than the original' );
|
||||
assert.strictEqual( provider.canHaveLargerThumbnailThanOriginal( file ), false, 'TIFF can\'t have a larger thumbnail than the original' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.gif' );
|
||||
|
||||
assert.ok( !provider.canHaveLargerThumbnailThanOriginal( file ), 'GIF can\'t have a larger thumbnail than the original' );
|
||||
assert.strictEqual( provider.canHaveLargerThumbnailThanOriginal( file ), false, 'GIF can\'t have a larger thumbnail than the original' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'canBeDisplayedInBrowser()', function ( assert ) {
|
||||
var provider = new mw.mmv.provider.GuessedThumbnailInfo(),
|
||||
file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
assert.ok( !provider.canBeDisplayedInBrowser( file ), 'SVG can\'t be displayed as-is in the browser' );
|
||||
assert.strictEqual( provider.canBeDisplayedInBrowser( file ), false, 'SVG can\'t be displayed as-is in the browser' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.jpg' );
|
||||
|
||||
assert.ok( provider.canBeDisplayedInBrowser( file ), 'JPG can be displayed as-is in the browser' );
|
||||
assert.strictEqual( provider.canBeDisplayedInBrowser( file ), true, 'JPG can be displayed as-is in the browser' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.png' );
|
||||
|
||||
assert.ok( provider.canBeDisplayedInBrowser( file ), 'PNG can be displayed as-is in the browser' );
|
||||
assert.strictEqual( provider.canBeDisplayedInBrowser( file ), true, 'PNG can be displayed as-is in the browser' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.jpeg' );
|
||||
|
||||
assert.ok( provider.canBeDisplayedInBrowser( file ), 'JPEG can be displayed as-is in the browser' );
|
||||
assert.strictEqual( provider.canBeDisplayedInBrowser( file ), true, 'JPEG can be displayed as-is in the browser' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.tiff' );
|
||||
|
||||
assert.ok( !provider.canBeDisplayedInBrowser( file ), 'TIFF can\'t be displayed as-is in the browser' );
|
||||
assert.strictEqual( provider.canBeDisplayedInBrowser( file ), false, 'TIFF can\'t be displayed as-is in the browser' );
|
||||
|
||||
file = new mw.Title( 'File:Foo.gif' );
|
||||
|
||||
assert.ok( provider.canBeDisplayedInBrowser( file ), 'GIF can be displayed as-is in the browser' );
|
||||
assert.strictEqual( provider.canBeDisplayedInBrowser( file ), true, 'GIF can be displayed as-is in the browser' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'guessWidth()', function ( assert ) {
|
||||
|
|
|
@ -28,16 +28,16 @@
|
|||
QUnit.test( 'isMediaViewerHash()', function ( assert ) {
|
||||
var router = new mw.mmv.routing.Router();
|
||||
|
||||
assert.ok( router.isMediaViewerHash( 'mediaviewer/foo' ), 'Legacy hash' );
|
||||
assert.ok( router.isMediaViewerHash( '#mediaviewer/foo' ), 'Legacy hash with #' );
|
||||
assert.ok( router.isMediaViewerHash( 'mediaviewer' ), 'Bare legacy hash' );
|
||||
assert.ok( router.isMediaViewerHash( '#mediaviewer' ), 'Bare legacy hash with #' );
|
||||
assert.ok( router.isMediaViewerHash( '/media/foo' ), 'Normal hash' );
|
||||
assert.ok( router.isMediaViewerHash( '#/media/foo' ), 'Normal hash with #' );
|
||||
assert.ok( router.isMediaViewerHash( '/media' ), 'Bare hash' );
|
||||
assert.ok( router.isMediaViewerHash( '#/media' ), 'Bare hash with #' );
|
||||
assert.ok( !router.isMediaViewerHash( 'foo/media' ), 'Foreign hash' );
|
||||
assert.ok( !router.isMediaViewerHash( '' ), 'Empty hash' );
|
||||
assert.strictEqual( router.isMediaViewerHash( 'mediaviewer/foo' ), true, 'Legacy hash' );
|
||||
assert.strictEqual( router.isMediaViewerHash( '#mediaviewer/foo' ), true, 'Legacy hash with #' );
|
||||
assert.strictEqual( router.isMediaViewerHash( 'mediaviewer' ), true, 'Bare legacy hash' );
|
||||
assert.strictEqual( router.isMediaViewerHash( '#mediaviewer' ), true, 'Bare legacy hash with #' );
|
||||
assert.strictEqual( router.isMediaViewerHash( '/media/foo' ), true, 'Normal hash' );
|
||||
assert.strictEqual( router.isMediaViewerHash( '#/media/foo' ), true, 'Normal hash with #' );
|
||||
assert.strictEqual( router.isMediaViewerHash( '/media' ), true, 'Bare hash' );
|
||||
assert.strictEqual( router.isMediaViewerHash( '#/media' ), true, 'Bare hash with #' );
|
||||
assert.strictEqual( router.isMediaViewerHash( 'foo/media' ), false, 'Foreign hash' );
|
||||
assert.strictEqual( router.isMediaViewerHash( '' ), false, 'Empty hash' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'createHash()/parseHash()', function ( assert ) {
|
||||
|
@ -79,7 +79,7 @@
|
|||
parsedRoute = router.parseHash( hash );
|
||||
assert.strictEqual( parsedRoute.fileTitle.getPrefixedDb(),
|
||||
title.getPrefixedDb(), 'Filename with /' );
|
||||
assert.ok( !hash.match( 'Foo/bar' ), '/ is encoded' );
|
||||
assert.notOk( hash.match( 'Foo/bar' ), '/ is encoded' );
|
||||
|
||||
title = new mw.Title( 'File:Foo bar.png' );
|
||||
route = new mw.mmv.routing.ThumbnailRoute( title );
|
||||
|
@ -87,7 +87,7 @@
|
|||
parsedRoute = router.parseHash( hash );
|
||||
assert.strictEqual( parsedRoute.fileTitle.getPrefixedDb(),
|
||||
title.getPrefixedDb(), 'Filename with space' );
|
||||
assert.ok( !hash.match( 'Foo bar' ), 'space is replaced...' );
|
||||
assert.notOk( hash.match( 'Foo bar' ), 'space is replaced...' );
|
||||
assert.ok( hash.match( 'Foo_bar' ), '...with underscore' );
|
||||
|
||||
title = new mw.Title( 'File:看門狗 (遊戲).jpg' );
|
||||
|
@ -126,10 +126,10 @@
|
|||
QUnit.test( 'parseHash() with invalid hashes', function ( assert ) {
|
||||
var router = new mw.mmv.routing.Router();
|
||||
|
||||
assert.ok( !router.parseHash( 'foo' ), 'Non-MMV hash is rejected.' );
|
||||
assert.ok( !router.parseHash( '#foo' ), 'Non-MMV hash is rejected (with #).' );
|
||||
assert.ok( !router.parseHash( '/media/foo/bar' ), 'Invalid MMV hash is rejected.' );
|
||||
assert.ok( !router.parseHash( '#/media/foo/bar' ), 'Invalid MMV hash is rejected (with #).' );
|
||||
assert.notOk( router.parseHash( 'foo' ), 'Non-MMV hash is rejected.' );
|
||||
assert.notOk( router.parseHash( '#foo' ), 'Non-MMV hash is rejected (with #).' );
|
||||
assert.notOk( router.parseHash( '/media/foo/bar' ), 'Invalid MMV hash is rejected.' );
|
||||
assert.notOk( router.parseHash( '#/media/foo/bar' ), 'Invalid MMV hash is rejected (with #).' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'parseHash() backwards compatibility', function ( assert ) {
|
||||
|
@ -171,7 +171,7 @@
|
|||
|
||||
location = { href: 'http://example.com/foo' };
|
||||
route = router.parseLocation( location );
|
||||
assert.ok( !route, 'Reading location without fragment part works' );
|
||||
assert.notOk( route, 'Reading location without fragment part works' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'parseLocation() with real location', function ( assert ) {
|
||||
|
|
|
@ -37,19 +37,19 @@
|
|||
canvas.empty();
|
||||
|
||||
assert.strictEqual( canvas.$imageDiv.html(), '', 'Canvas is empty.' );
|
||||
assert.ok( canvas.$imageDiv.hasClass( 'empty' ), 'Canvas is not visible.' );
|
||||
assert.strictEqual( canvas.$imageDiv.hasClass( 'empty' ), true, 'Canvas is not visible.' );
|
||||
|
||||
canvas.set( imageRawMetadata, $imageElem );
|
||||
|
||||
assert.strictEqual( canvas.$image, $imageElem, 'Image element set correctly.' );
|
||||
assert.strictEqual( canvas.imageRawMetadata, imageRawMetadata, 'Raw metadata set correctly.' );
|
||||
assert.strictEqual( canvas.$imageDiv.html(), '<img>', 'Image added to container.' );
|
||||
assert.ok( !canvas.$imageDiv.hasClass( 'empty' ), 'Canvas is visible.' );
|
||||
assert.strictEqual( canvas.$imageDiv.hasClass( 'empty' ), false, 'Canvas is visible.' );
|
||||
|
||||
canvas.empty();
|
||||
|
||||
assert.strictEqual( canvas.$imageDiv.html(), '', 'Canvas is empty.' );
|
||||
assert.ok( canvas.$imageDiv.hasClass( 'empty' ), 'Canvas is not visible.' );
|
||||
assert.strictEqual( canvas.$imageDiv.hasClass( 'empty' ), true, 'Canvas is not visible.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'setImageAndMaxDimensions()', function ( assert ) {
|
||||
|
@ -121,8 +121,8 @@
|
|||
|
||||
assert.strictEqual( $image.width(), 10, 'Placeholder width was not set to max' );
|
||||
assert.strictEqual( $image.height(), 5, 'Placeholder height was not set to max' );
|
||||
assert.ok( !$image.hasClass( 'blurred' ), 'Placeholder is not blurred' );
|
||||
assert.ok( !blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( $image.hasClass( 'blurred' ), false, 'Placeholder is not blurred' );
|
||||
assert.strictEqual( blurredThumbnailShown, false, 'Placeholder state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'maybeDisplayPlaceholder: placeholder big enough that it doesn\'t need blurring, actual image bigger than the lightbox', function ( assert ) {
|
||||
|
@ -151,8 +151,8 @@
|
|||
|
||||
assert.strictEqual( $image.width(), 300, 'Placeholder has the right width' );
|
||||
assert.strictEqual( $image.height(), 150, 'Placeholder has the right height' );
|
||||
assert.ok( !$image.hasClass( 'blurred' ), 'Placeholder is not blurred' );
|
||||
assert.ok( !blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( $image.hasClass( 'blurred' ), false, 'Placeholder is not blurred' );
|
||||
assert.strictEqual( blurredThumbnailShown, false, 'Placeholder state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'maybeDisplayPlaceholder: big-enough placeholder that needs blurring, actual image bigger than the lightbox', function ( assert ) {
|
||||
|
@ -181,8 +181,8 @@
|
|||
|
||||
assert.strictEqual( $image.width(), 300, 'Placeholder has the right width' );
|
||||
assert.strictEqual( $image.height(), 150, 'Placeholder has the right height' );
|
||||
assert.ok( $image.hasClass( 'blurred' ), 'Placeholder is blurred' );
|
||||
assert.ok( blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( $image.hasClass( 'blurred' ), true, 'Placeholder is blurred' );
|
||||
assert.strictEqual( blurredThumbnailShown, true, 'Placeholder state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'maybeDisplayPlaceholder: big-enough placeholder that needs blurring, actual image smaller than the lightbox', function ( assert ) {
|
||||
|
@ -211,8 +211,8 @@
|
|||
|
||||
assert.strictEqual( $image.width(), 1000, 'Placeholder has the right width' );
|
||||
assert.strictEqual( $image.height(), 500, 'Placeholder has the right height' );
|
||||
assert.ok( $image.hasClass( 'blurred' ), 'Placeholder is blurred' );
|
||||
assert.ok( blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( $image.hasClass( 'blurred' ), true, 'Placeholder is blurred' );
|
||||
assert.strictEqual( blurredThumbnailShown, true, 'Placeholder state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'maybeDisplayPlaceholder: placeholder too small to be displayed, actual image bigger than the lightbox', function ( assert ) {
|
||||
|
@ -241,8 +241,8 @@
|
|||
|
||||
assert.strictEqual( $image.width(), 10, 'Placeholder has the right width' );
|
||||
assert.strictEqual( $image.height(), 5, 'Placeholder has the right height' );
|
||||
assert.ok( !$image.hasClass( 'blurred' ), 'Placeholder is not blurred' );
|
||||
assert.ok( !blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
assert.strictEqual( $image.hasClass( 'blurred' ), false, 'Placeholder is not blurred' );
|
||||
assert.strictEqual( blurredThumbnailShown, false, 'Placeholder state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Unblur', function ( assert ) {
|
||||
|
@ -279,7 +279,7 @@
|
|||
'Image has no filter left' );
|
||||
assert.strictEqual( parseInt( canvas.$image.css( 'opacity' ), 10 ), 1,
|
||||
'Image is fully opaque' );
|
||||
assert.ok( !canvas.$image.hasClass( 'blurred' ), 'Image has no "blurred" class' );
|
||||
assert.strictEqual( canvas.$image.hasClass( 'blurred' ), false, 'Image has no "blurred" class' );
|
||||
|
||||
$.fn.animate = oldAnimate;
|
||||
} );
|
||||
|
|
|
@ -13,19 +13,19 @@
|
|||
var description = new mw.mmv.ui.Description( $( '#qunit-fixture' ) );
|
||||
|
||||
description.set( null, null );
|
||||
assert.ok( description.$imageDescDiv.hasClass( 'empty' ),
|
||||
assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), true,
|
||||
'Image description div is marked empty when neither description nor caption is available' );
|
||||
|
||||
description.set( null, 'foo' );
|
||||
assert.ok( description.$imageDescDiv.hasClass( 'empty' ),
|
||||
assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), true,
|
||||
'Image description div is marked empty when there is no description' );
|
||||
|
||||
description.set( 'blah', null );
|
||||
assert.ok( description.$imageDescDiv.hasClass( 'empty' ),
|
||||
assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), true,
|
||||
'Image description div is marked empty when there is no caption (description will be shown in title)' );
|
||||
|
||||
description.set( 'foo', 'bar' );
|
||||
assert.ok( !description.$imageDescDiv.hasClass( 'empty' ),
|
||||
assert.strictEqual( description.$imageDescDiv.hasClass( 'empty' ), false,
|
||||
'Image description div is not marked empty when both description and caption are available' );
|
||||
assert.strictEqual( description.$imageDesc.text(), 'foo',
|
||||
'Image description text is set correctly, caption is ignored' );
|
||||
|
|
|
@ -77,8 +77,8 @@
|
|||
'choose', download.downloadSizeMenu.getMenu().findSelectedItem() );
|
||||
download.$selectionArrow.trigger( 'click' );
|
||||
|
||||
assert.ok( !hsstub.called, 'handleSizeSwitch not called' );
|
||||
assert.ok( !tstub.called, 'Menu selection did not happen' );
|
||||
assert.strictEqual( hsstub.called, false, 'handleSizeSwitch not called' );
|
||||
assert.strictEqual( tstub.called, false, 'Menu selection did not happen' );
|
||||
|
||||
hsstub.reset();
|
||||
tstub.reset();
|
||||
|
@ -90,8 +90,8 @@
|
|||
'choose', download.downloadSizeMenu.getMenu().findSelectedItem() );
|
||||
download.$selectionArrow.trigger( 'click' );
|
||||
|
||||
assert.ok( hsstub.called, 'handleSizeSwitch was called' );
|
||||
assert.ok( tstub.called, 'Menu selection happened' );
|
||||
assert.strictEqual( hsstub.called, true, 'handleSizeSwitch was called' );
|
||||
assert.strictEqual( tstub.called, true, 'Menu selection happened' );
|
||||
|
||||
hsstub.reset();
|
||||
tstub.reset();
|
||||
|
@ -103,8 +103,8 @@
|
|||
'choose', download.downloadSizeMenu.getMenu().findSelectedItem() );
|
||||
download.$selectionArrow.trigger( 'click' );
|
||||
|
||||
assert.ok( !hsstub.called, 'handleSizeSwitch not called' );
|
||||
assert.ok( !tstub.called, 'Menu selection did not happen' );
|
||||
assert.strictEqual( hsstub.called, false, 'handleSizeSwitch not called' );
|
||||
assert.strictEqual( tstub.called, false, 'Menu selection did not happen' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'handleSizeSwitch():', function ( assert ) {
|
||||
|
@ -159,6 +159,6 @@
|
|||
|
||||
assert.strictEqual( download.$downloadButton.attr( 'href' ), imageUrl + '?download', 'Download link is set correctly.' );
|
||||
assert.strictEqual( download.$previewLink.attr( 'href' ), imageUrl, 'Preview link is set correctly.' );
|
||||
assert.ok( !download.$downloadButton.hasClass( 'disabledLink' ), 'Download link is enabled.' );
|
||||
assert.strictEqual( download.$downloadButton.hasClass( 'disabledLink' ), false, 'Download link is enabled.' );
|
||||
} );
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
|
@ -131,9 +131,9 @@
|
|||
assert.ok( panel.$credit.text(), 'Default credit is shown' );
|
||||
assert.strictEqual( panel.$license.prop( 'href' ), imageData.descriptionUrl,
|
||||
'User is directed to file page for license information' );
|
||||
assert.ok( !panel.$license.prop( 'target' ), 'License information opens in same window' );
|
||||
assert.ok( panel.$datetimeLi.hasClass( 'empty' ), 'Date/Time is empty' );
|
||||
assert.ok( panel.$locationLi.hasClass( 'empty' ), 'Location is empty' );
|
||||
assert.notOk( panel.$license.prop( 'target' ), 'License information opens in same window' );
|
||||
assert.strictEqual( panel.$datetimeLi.hasClass( 'empty' ), true, 'Date/Time is empty' );
|
||||
assert.strictEqual( panel.$locationLi.hasClass( 'empty' ), true, 'Location is empty' );
|
||||
|
||||
imageData.creationDateTime = '2013-08-26T14:41:02Z';
|
||||
imageData.uploadDateTime = '2013-08-25T14:41:02Z';
|
||||
|
@ -149,8 +149,8 @@
|
|||
clock.tick( 10 );
|
||||
|
||||
assert.strictEqual( panel.$title.text(), title, 'Title is correctly set' );
|
||||
assert.ok( !panel.$credit.hasClass( 'empty' ), 'Credit is not empty' );
|
||||
assert.ok( !panel.$datetimeLi.hasClass( 'empty' ), 'Date/Time is not empty' );
|
||||
assert.strictEqual( panel.$credit.hasClass( 'empty' ), false, 'Credit is not empty' );
|
||||
assert.strictEqual( panel.$datetimeLi.hasClass( 'empty' ), false, 'Date/Time is not empty' );
|
||||
assert.strictEqual( panel.creditField.$element.find( '.mw-mmv-author' ).text(), imageData.author, 'Author text is correctly set' );
|
||||
assert.strictEqual( panel.creditField.$element.find( '.mw-mmv-source' ).html(), '<b>Lost</b><a href="foo">Bar</a>', 'Source text is correctly set' );
|
||||
// Either multimediaviewer-credit-popup-text or multimediaviewer-credit-popup-text-more.
|
||||
|
@ -158,7 +158,7 @@
|
|||
assert.ok( panel.$datetime.text().indexOf( '26 August 2013' ) > 0, 'Correct date is displayed' );
|
||||
assert.strictEqual( panel.$license.text(), 'CC BY 2.0', 'License is correctly set' );
|
||||
assert.ok( panel.$license.prop( 'target' ), 'License information opens in new window' );
|
||||
assert.ok( panel.$restrictions.children().last().children().hasClass( 'mw-mmv-restriction-default' ), 'Default restriction is correctly displayed last' );
|
||||
assert.strictEqual( panel.$restrictions.children().last().children().hasClass( 'mw-mmv-restriction-default' ), true, 'Default restriction is correctly displayed last' );
|
||||
|
||||
imageData.creationDateTime = undefined;
|
||||
panel.setImageInfo( image, imageData, repoData );
|
||||
|
@ -176,7 +176,7 @@
|
|||
|
||||
panel.setLicense( null, 'http://example.com' ); // make sure license is visible as it contains the permission
|
||||
panel.setPermission( 'Look at me, I am a permission!' );
|
||||
assert.ok( panel.$permissionLink.is( ':visible' ) );
|
||||
assert.strictEqual( panel.$permissionLink.is( ':visible' ), true );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Date formatting', function ( assert ) {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
scroller = new mw.mmv.ui.MetadataPanelScroller( $qf, $( '<div>' ).appendTo( $qf ), localStorage );
|
||||
|
||||
scroller.empty();
|
||||
assert.ok( !scroller.$container.hasClass( 'invite' ), 'We successfully reset the invite' );
|
||||
assert.strictEqual( scroller.$container.hasClass( 'invite' ), false, 'We successfully reset the invite' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Metadata div is only animated once', function ( assert ) {
|
||||
|
@ -55,7 +55,7 @@
|
|||
scroller.animateMetadataOnce();
|
||||
|
||||
assert.strictEqual( scroller.hasAnimatedMetadata, true, 'The second call to animateMetadataOnce did not change the value of hasAnimatedMetadata' );
|
||||
assert.ok( !$qf.hasClass( 'invite' ),
|
||||
assert.strictEqual( $qf.hasClass( 'invite' ), false,
|
||||
'The second call to animateMetadataOnce did not lead to an animation' );
|
||||
|
||||
scroller.unattach();
|
||||
|
@ -157,12 +157,12 @@
|
|||
|
||||
assert.strictEqual( $window.scrollTop(), 0, 'scrollTop should be set to 0' );
|
||||
|
||||
assert.ok( !fakeLocalStorage.store.setItem.called, 'The metadata hasn\'t been open yet, no entry in localStorage' );
|
||||
assert.strictEqual( fakeLocalStorage.store.setItem.called, false, 'The metadata hasn\'t been open yet, no entry in localStorage' );
|
||||
|
||||
keydown.which = 38; // Up arrow
|
||||
scroller.keydown( keydown );
|
||||
|
||||
assert.ok( fakeLocalStorage.store.setItem.calledWithExactly( 'mmv.hasOpenedMetadata', '1' ), 'localStorage knows that the metadata has been open' );
|
||||
assert.strictEqual( fakeLocalStorage.store.setItem.calledWithExactly( 'mmv.hasOpenedMetadata', '1' ), true, 'localStorage knows that the metadata has been open' );
|
||||
|
||||
keydown.which = 40; // Down arrow
|
||||
scroller.keydown( keydown );
|
||||
|
@ -208,25 +208,25 @@
|
|||
keydown.which = 38; // Up arrow
|
||||
scroller.keydown( keydown );
|
||||
|
||||
assert.ok( mw.mmv.actionLogger.log.calledWithExactly( 'metadata-open' ), 'Opening keypress logged' );
|
||||
assert.strictEqual( mw.mmv.actionLogger.log.calledWithExactly( 'metadata-open' ), true, 'Opening keypress logged' );
|
||||
mw.mmv.actionLogger.log.reset();
|
||||
|
||||
keydown.which = 38; // Up arrow
|
||||
scroller.keydown( keydown );
|
||||
|
||||
assert.ok( mw.mmv.actionLogger.log.calledWithExactly( 'metadata-close' ), 'Closing keypress logged' );
|
||||
assert.strictEqual( mw.mmv.actionLogger.log.calledWithExactly( 'metadata-close' ), true, 'Closing keypress logged' );
|
||||
mw.mmv.actionLogger.log.reset();
|
||||
|
||||
keydown.which = 40; // Down arrow
|
||||
scroller.keydown( keydown );
|
||||
|
||||
assert.ok( mw.mmv.actionLogger.log.calledWithExactly( 'metadata-open' ), 'Opening keypress logged' );
|
||||
assert.strictEqual( mw.mmv.actionLogger.log.calledWithExactly( 'metadata-open' ), true, 'Opening keypress logged' );
|
||||
mw.mmv.actionLogger.log.reset();
|
||||
|
||||
keydown.which = 40; // Down arrow
|
||||
scroller.keydown( keydown );
|
||||
|
||||
assert.ok( mw.mmv.actionLogger.log.calledWithExactly( 'metadata-close' ), 'Closing keypress logged' );
|
||||
assert.strictEqual( mw.mmv.actionLogger.log.calledWithExactly( 'metadata-close' ), true, 'Closing keypress logged' );
|
||||
mw.mmv.actionLogger.log.reset();
|
||||
} );
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
|
@ -41,9 +41,9 @@
|
|||
assert.strictEqual( permission.$text.children().remove().end().text(),
|
||||
text, 'permission text is set' );
|
||||
assert.strictEqual( permission.$html.text(), text, 'permission html is set' );
|
||||
assert.ok( permission.$text.is( ':visible' ), 'permission text is visible' );
|
||||
assert.ok( !permission.$html.is( ':visible' ), 'permission html is not visible' );
|
||||
assert.ok( !permission.$close.is( ':visible' ), 'close button is not visible' );
|
||||
assert.strictEqual( permission.$text.is( ':visible' ), true, 'permission text is visible' );
|
||||
assert.strictEqual( permission.$html.is( ':visible' ), false, 'permission html is not visible' );
|
||||
assert.strictEqual( permission.$close.is( ':visible' ), false, 'close button is not visible' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'set() with html', function ( assert ) {
|
||||
|
@ -53,8 +53,8 @@
|
|||
|
||||
permission.set( text );
|
||||
|
||||
assert.ok( !permission.$text.find( 'b' ).length, 'permission text has no html' );
|
||||
assert.ok( permission.$html.find( 'b' ), 'permission html has html' );
|
||||
assert.strictEqual( permission.$text.find( 'b' ).length, 0, 'permission text has no html' );
|
||||
assert.strictEqual( permission.$html.find( 'b' ).length, 1, 'permission html has html' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'empty()', function ( assert ) {
|
||||
|
@ -65,9 +65,9 @@
|
|||
permission.set( text );
|
||||
permission.empty();
|
||||
|
||||
assert.ok( !permission.$text.is( ':visible' ), 'permission text is not visible' );
|
||||
assert.ok( !permission.$html.is( ':visible' ), 'permission html is not visible' );
|
||||
assert.ok( !permission.$close.is( ':visible' ), 'close button is not visible' );
|
||||
assert.strictEqual( permission.$text.is( ':visible' ), false, 'permission text is not visible' );
|
||||
assert.strictEqual( permission.$html.is( ':visible' ), false, 'permission html is not visible' );
|
||||
assert.strictEqual( permission.$close.is( ':visible' ), false, 'close button is not visible' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'grow()', function ( assert ) {
|
||||
|
@ -78,9 +78,9 @@
|
|||
permission.set( text );
|
||||
permission.grow();
|
||||
|
||||
assert.ok( !permission.$text.is( ':visible' ), 'permission text is not visible' );
|
||||
assert.ok( permission.$html.is( ':visible' ), 'permission html is visible' );
|
||||
assert.ok( permission.$close.is( ':visible' ), 'close button is visible' );
|
||||
assert.strictEqual( permission.$text.is( ':visible' ), false, 'permission text is not visible' );
|
||||
assert.strictEqual( permission.$html.is( ':visible' ), true, 'permission html is visible' );
|
||||
assert.strictEqual( permission.$close.is( ':visible' ), true, 'close button is visible' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'shrink()', function ( assert ) {
|
||||
|
@ -92,9 +92,9 @@
|
|||
permission.grow();
|
||||
permission.shrink();
|
||||
|
||||
assert.ok( permission.$text.is( ':visible' ), 'permission text is visible' );
|
||||
assert.ok( !permission.$html.is( ':visible' ), 'permission html is not visible' );
|
||||
assert.ok( !permission.$close.is( ':visible' ), 'close button is not visible' );
|
||||
assert.strictEqual( permission.$text.is( ':visible' ), true, 'permission text is visible' );
|
||||
assert.strictEqual( permission.$html.is( ':visible' ), false, 'permission html is not visible' );
|
||||
assert.strictEqual( permission.$close.is( ':visible' ), false, 'close button is not visible' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'isFullSize()', function ( assert ) {
|
||||
|
@ -103,10 +103,10 @@
|
|||
text = 'Nothing to see here.';
|
||||
|
||||
permission.set( text );
|
||||
assert.ok( !permission.isFullSize(), 'permission is not full-size' );
|
||||
assert.strictEqual( permission.isFullSize(), false, 'permission is not full-size' );
|
||||
permission.grow();
|
||||
assert.ok( permission.isFullSize(), 'permission is full-size' );
|
||||
assert.strictEqual( permission.isFullSize(), true, 'permission is full-size' );
|
||||
permission.shrink();
|
||||
assert.ok( !permission.isFullSize(), 'permission is not full-size again' );
|
||||
assert.strictEqual( permission.isFullSize(), false, 'permission is not full-size again' );
|
||||
} );
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
QUnit.test( 'Constructor sanity check', function ( assert ) {
|
||||
var progressBar = new mw.mmv.ui.ProgressBar( $( '<div>' ) );
|
||||
assert.ok( progressBar, 'ProgressBar created sccessfully' );
|
||||
assert.ok( progressBar.$progress.hasClass( 'empty' ), 'ProgressBar starts empty' );
|
||||
assert.strictEqual( progressBar.$progress.hasClass( 'empty' ), true, 'ProgressBar starts empty' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'animateTo()', function ( assert ) {
|
||||
|
@ -29,7 +29,7 @@
|
|||
$div = $( '<div>' ).css( { width: 250, position: 'relative' } ).appendTo( $qf ),
|
||||
progress = new mw.mmv.ui.ProgressBar( $div );
|
||||
|
||||
assert.ok( progress.$progress.hasClass( 'empty' ), 'Progress bar is hidden' );
|
||||
assert.strictEqual( progress.$progress.hasClass( 'empty' ), true, 'Progress bar is hidden' );
|
||||
assert.strictEqual( progress.$percent.width(), 0, 'Progress bar\'s indicator is at 0' );
|
||||
|
||||
this.sandbox.stub( $.fn, 'animate', function ( target ) {
|
||||
|
@ -37,7 +37,7 @@
|
|||
assert.strictEqual( target.width, '50%', 'Animation should go to 50%' );
|
||||
} );
|
||||
progress.animateTo( 50 );
|
||||
assert.ok( !progress.$progress.hasClass( 'empty' ), 'Progress bar is visible' );
|
||||
assert.strictEqual( progress.$progress.hasClass( 'empty' ), false, 'Progress bar is visible' );
|
||||
|
||||
assert.strictEqual( progress.$percent.width(), 125, 'Progress bar\'s indicator is at half' );
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
|||
}
|
||||
} );
|
||||
progress.animateTo( 100 );
|
||||
assert.ok( progress.$progress.hasClass( 'empty' ), 'Progress bar is hidden' );
|
||||
assert.strictEqual( progress.$progress.hasClass( 'empty' ), true, 'Progress bar is hidden' );
|
||||
assert.strictEqual( progress.$percent.width(), 0, 'Progress bar\'s indicator is at 0' );
|
||||
} );
|
||||
|
||||
|
@ -61,17 +61,17 @@
|
|||
$div = $( '<div>' ).css( { width: 250, position: 'relative' } ).appendTo( $qf ),
|
||||
progress = new mw.mmv.ui.ProgressBar( $div );
|
||||
|
||||
assert.ok( progress.$progress.hasClass( 'empty' ), 'Progress bar is hidden' );
|
||||
assert.strictEqual( progress.$progress.hasClass( 'empty' ), true, 'Progress bar is hidden' );
|
||||
assert.strictEqual( progress.$percent.width(), 0, 'Progress bar\'s indicator is at 0' );
|
||||
|
||||
progress.jumpTo( 50 );
|
||||
|
||||
assert.ok( !progress.$progress.hasClass( 'empty' ), 'Progress bar is visible' );
|
||||
assert.strictEqual( progress.$progress.hasClass( 'empty' ), false, 'Progress bar is visible' );
|
||||
assert.strictEqual( progress.$percent.width(), 125, 'Progress bar\'s indicator is at half' );
|
||||
|
||||
progress.hide();
|
||||
|
||||
assert.ok( progress.$progress.hasClass( 'empty' ), 'Progress bar is hidden' );
|
||||
assert.strictEqual( progress.$progress.hasClass( 'empty' ), true, 'Progress bar is hidden' );
|
||||
assert.strictEqual( progress.$percent.width(), 0, 'Progress bar\'s indicator is at 0' );
|
||||
} );
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
|
@ -63,15 +63,15 @@
|
|||
|
||||
// Share pane is selected
|
||||
reuseDialog.handleTabSelection( { getData: function () { return 'share'; } } );
|
||||
assert.ok( reuseDialog.tabs.share.$pane.hasClass( 'active' ), 'Share tab shown.' );
|
||||
assert.ok( !reuseDialog.tabs.embed.$pane.hasClass( 'active' ), 'Embed tab hidden.' );
|
||||
assert.ok( reuseDialog.config.setInLocalStorage.calledWith( 'mmv-lastUsedTab', 'share' ),
|
||||
assert.strictEqual( reuseDialog.tabs.share.$pane.hasClass( 'active' ), true, 'Share tab shown.' );
|
||||
assert.strictEqual( reuseDialog.tabs.embed.$pane.hasClass( 'active' ), false, 'Embed tab hidden.' );
|
||||
assert.strictEqual( reuseDialog.config.setInLocalStorage.calledWith( 'mmv-lastUsedTab', 'share' ), true,
|
||||
'Tab state saved in local storage.' );
|
||||
|
||||
// Embed pane is selected
|
||||
reuseDialog.handleTabSelection( { getData: function () { return 'embed'; } } );
|
||||
assert.ok( !reuseDialog.tabs.share.$pane.hasClass( 'active' ), 'Share tab hidden.' );
|
||||
assert.ok( reuseDialog.tabs.embed.$pane.hasClass( 'active' ), 'Embed tab shown.' );
|
||||
assert.strictEqual( reuseDialog.tabs.share.$pane.hasClass( 'active' ), false, 'Share tab hidden.' );
|
||||
assert.strictEqual( reuseDialog.tabs.embed.$pane.hasClass( 'active' ), true, 'Embed tab shown.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'default tab:', function ( assert ) {
|
||||
|
@ -152,19 +152,19 @@
|
|||
var event;
|
||||
reuseDialog.closeDialog = function () { assert.ok( false, 'Dialog is not affected by click' ); };
|
||||
event = clickOutsideDialog();
|
||||
assert.ok( !event.isDefaultPrevented(), 'Dialog does not affect click' );
|
||||
assert.ok( !event.isPropagationStopped(), 'Dialog does not affect click propagation' );
|
||||
assert.strictEqual( event.isDefaultPrevented(), false, 'Dialog does not affect click' );
|
||||
assert.strictEqual( event.isPropagationStopped(), false, 'Dialog does not affect click propagation' );
|
||||
}
|
||||
function assertDialogCatchesOutsideClicksOnly() {
|
||||
var event;
|
||||
reuseDialog.closeDialog = function () { assert.ok( false, 'Dialog is not affected by inside click' ); };
|
||||
event = clickInsideDialog();
|
||||
assert.ok( !event.isDefaultPrevented(), 'Dialog does not affect inside click' );
|
||||
assert.ok( !event.isPropagationStopped(), 'Dialog does not affect inside click propagation' );
|
||||
assert.strictEqual( event.isDefaultPrevented(), false, 'Dialog does not affect inside click' );
|
||||
assert.strictEqual( event.isPropagationStopped(), false, 'Dialog does not affect inside click propagation' );
|
||||
reuseDialog.closeDialog = function () { assert.ok( true, 'Dialog is closed by outside click' ); };
|
||||
event = clickOutsideDialog();
|
||||
assert.ok( event.isDefaultPrevented(), 'Dialog catches outside click' );
|
||||
assert.ok( event.isPropagationStopped(), 'Dialog stops outside click propagation' );
|
||||
assert.strictEqual( event.isDefaultPrevented(), true, 'Dialog catches outside click' );
|
||||
assert.strictEqual( event.isPropagationStopped(), true, 'Dialog stops outside click propagation' );
|
||||
}
|
||||
|
||||
assertDialogDoesNotCatchClicks();
|
||||
|
@ -215,15 +215,15 @@
|
|||
|
||||
reuseDialog.set( image, repoInfo );
|
||||
|
||||
assert.ok( !reuseDialog.isOpen, 'Dialog closed by default.' );
|
||||
assert.strictEqual( reuseDialog.isOpen, false, 'Dialog closed by default.' );
|
||||
|
||||
reuseDialog.openDialog();
|
||||
|
||||
assert.ok( reuseDialog.isOpen, 'Dialog open now.' );
|
||||
assert.strictEqual( reuseDialog.isOpen, true, 'Dialog open now.' );
|
||||
|
||||
reuseDialog.closeDialog();
|
||||
|
||||
assert.ok( !reuseDialog.isOpen, 'Dialog closed now.' );
|
||||
assert.strictEqual( reuseDialog.isOpen, false, 'Dialog closed now.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getImageWarnings():', function ( assert ) {
|
||||
|
|
|
@ -244,11 +244,11 @@
|
|||
calledSelect = true;
|
||||
};
|
||||
|
||||
assert.ok( !embed.embedFileInfo, 'embedFileInfo not set yet.' );
|
||||
assert.notOk( embed.embedFileInfo, 'embedFileInfo not set yet.' );
|
||||
|
||||
embed.set( { width: width, height: height }, embedFileInfo );
|
||||
|
||||
assert.ok( embed.embedFileInfo, 'embedFileInfo correctly set.' );
|
||||
assert.ok( embed.embedFileInfo, 'embedFileInfo set.' );
|
||||
assert.strictEqual( embed.isSizeMenuDefaultReset, false, 'Reset flag cleared.' );
|
||||
assert.strictEqual( calledSelect, true, 'select() is called' );
|
||||
} );
|
||||
|
@ -274,8 +274,8 @@
|
|||
|
||||
assert.strictEqual( embed.embedTextHtml.getValue(), '', 'embedTextHtml is empty.' );
|
||||
assert.strictEqual( embed.embedTextWikitext.getValue(), '', 'embedTextWikitext is empty.' );
|
||||
assert.ok( !embed.embedSizeSwitchHtml.getMenu().isVisible(), 'Html size menu should be hidden.' );
|
||||
assert.ok( !embed.embedSizeSwitchWikitext.getMenu().isVisible(), 'Wikitext size menu should be hidden.' );
|
||||
assert.strictEqual( embed.embedSizeSwitchHtml.getMenu().isVisible(), false, 'Html size menu should be hidden.' );
|
||||
assert.strictEqual( embed.embedSizeSwitchWikitext.getMenu().isVisible(), false, 'Wikitext size menu should be hidden.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'attach()/unattach():', function ( assert ) {
|
||||
|
@ -366,7 +366,7 @@
|
|||
embed.handleTypeSwitch( { getData: function () { return 'html'; } } );
|
||||
|
||||
assert.strictEqual( embed.isSizeMenuDefaultReset, true, 'Reset flag updated correctly.' );
|
||||
assert.ok( !embed.embedSizeSwitchWikitext.getMenu().isVisible(), 'Wikitext size menu should be hidden.' );
|
||||
assert.strictEqual( embed.embedSizeSwitchWikitext.getMenu().isVisible(), false, 'Wikitext size menu should be hidden.' );
|
||||
|
||||
embed.resetCurrentSizeMenuToDefault = function () {
|
||||
assert.ok( false, 'resetCurrentSizeMenuToDefault() should not have been called.' );
|
||||
|
@ -376,7 +376,7 @@
|
|||
embed.handleTypeSwitch( { getData: function () { return 'wikitext'; } } );
|
||||
|
||||
assert.strictEqual( embed.isSizeMenuDefaultReset, true, 'Reset flag updated correctly.' );
|
||||
assert.ok( !embed.embedSizeSwitchHtml.getMenu().isVisible(), 'HTML size menu should be hidden.' );
|
||||
assert.strictEqual( embed.embedSizeSwitchHtml.getMenu().isVisible(), false, 'HTML size menu should be hidden.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Logged out', function ( assert ) {
|
||||
|
@ -387,10 +387,10 @@
|
|||
|
||||
embed = new mw.mmv.ui.reuse.Embed( $qf );
|
||||
|
||||
assert.ok( !embed.embedSizeSwitchWikitext.$element.hasClass( 'active' ), 'Wikitext widget should be hidden.' );
|
||||
assert.ok( embed.embedSizeSwitchHtml.$element.hasClass( 'active' ), 'HTML widget should be visible.' );
|
||||
assert.ok( !embed.embedTextWikitext.$element.hasClass( 'active' ), 'Wikitext input should be hidden.' );
|
||||
assert.ok( embed.embedTextHtml.$element.hasClass( 'active' ), 'HTML input should be visible.' );
|
||||
assert.strictEqual( embed.embedSizeSwitchWikitext.$element.hasClass( 'active' ), false, 'Wikitext widget should be hidden.' );
|
||||
assert.strictEqual( embed.embedSizeSwitchHtml.$element.hasClass( 'active' ), true, 'HTML widget should be visible.' );
|
||||
assert.strictEqual( embed.embedTextWikitext.$element.hasClass( 'active' ), false, 'Wikitext input should be hidden.' );
|
||||
assert.strictEqual( embed.embedTextHtml.$element.hasClass( 'active' ), true, 'HTML input should be visible.' );
|
||||
|
||||
mw.user.isAnon = oldUserIsAnon;
|
||||
} );
|
||||
|
|
|
@ -30,14 +30,14 @@
|
|||
assert.ok( reuseTab, 'Reuse UI element is created.' );
|
||||
assert.strictEqual( reuseTab.$pane.length, 1, 'Pane created.' );
|
||||
|
||||
assert.ok( !reuseTab.$pane.hasClass( 'active' ), 'Tab is not active.' );
|
||||
assert.strictEqual( reuseTab.$pane.hasClass( 'active' ), false, 'Tab is not active.' );
|
||||
|
||||
reuseTab.show();
|
||||
|
||||
assert.ok( reuseTab.$pane.hasClass( 'active' ), 'Tab is active.' );
|
||||
assert.strictEqual( reuseTab.$pane.hasClass( 'active' ), true, 'Tab is active.' );
|
||||
|
||||
reuseTab.hide();
|
||||
|
||||
assert.ok( !reuseTab.$pane.hasClass( 'active' ), 'Tab is not active.' );
|
||||
assert.strictEqual( reuseTab.$pane.hasClass( 'active' ), false, 'Tab is not active.' );
|
||||
} );
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
|
@ -64,13 +64,13 @@
|
|||
|
||||
buttons.setDescriptionPageButton( imageInfo, repoInfo );
|
||||
|
||||
assert.ok( !button.hasClass( 'mw-mmv-repo-button-commons' ), 'Button does not have commons class non-Commons files' );
|
||||
assert.strictEqual( button.hasClass( 'mw-mmv-repo-button-commons' ), false, 'Button does not have commons class non-Commons files' );
|
||||
assert.strictEqual( button.find( 'a' ).addBack().filter( 'a' ).attr( 'href' ), descriptionUrl, 'Description page link is correct' );
|
||||
|
||||
repoInfo.isCommons = function () { return true; };
|
||||
buttons.setDescriptionPageButton( imageInfo, repoInfo );
|
||||
|
||||
assert.ok( button.hasClass( 'mw-mmv-repo-button-commons' ), 'Button commons class for Commons files' );
|
||||
assert.strictEqual( button.hasClass( 'mw-mmv-repo-button-commons' ), true, 'Button commons class for Commons files' );
|
||||
} );
|
||||
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
element.setInlineStyle( 'test', '#mmv-testdiv { display: none; }' );
|
||||
|
||||
assert.ok( !$testDiv.is( ':visible' ), 'Test div is hidden by inline style' );
|
||||
assert.strictEqual( $testDiv.is( ':visible' ), false, 'Test div is hidden by inline style' );
|
||||
|
||||
element.setInlineStyle( 'test', null );
|
||||
|
||||
assert.ok( $testDiv.is( ':visible' ), 'Test div is visible again' );
|
||||
assert.strictEqual( $testDiv.is( ':visible' ), true, 'Test div is visible again' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'setTimer()/clearTimer()/resetTimer()', function ( assert ) {
|
||||
|
@ -42,54 +42,54 @@
|
|||
|
||||
element.setTimer( 'foo', spy, 10 );
|
||||
this.clock.tick( 100 );
|
||||
assert.ok( spy.called, 'Timeout callback was called' );
|
||||
assert.ok( spy.calledOnce, 'Timeout callback was called once' );
|
||||
assert.ok( spy.calledOn( element ), 'Timeout callback was called on the element' );
|
||||
assert.strictEqual( spy.called, true, 'Timeout callback was called' );
|
||||
assert.strictEqual( spy.calledOnce, true, 'Timeout callback was called once' );
|
||||
assert.strictEqual( spy.calledOn( element ), true, 'Timeout callback was called on the element' );
|
||||
|
||||
spy = this.sandbox.spy();
|
||||
element.setTimer( 'foo', spy, 10 );
|
||||
element.setTimer( 'foo', spy2, 20 );
|
||||
this.clock.tick( 100 );
|
||||
assert.ok( !spy.called, 'Old timeout callback was not called after update' );
|
||||
assert.ok( spy2.called, 'New timeout callback was called after update' );
|
||||
assert.strictEqual( spy.called, false, 'Old timeout callback was not called after update' );
|
||||
assert.strictEqual( spy2.called, true, 'New timeout callback was called after update' );
|
||||
|
||||
spy = this.sandbox.spy();
|
||||
spy2 = this.sandbox.spy();
|
||||
element.setTimer( 'foo', spy, 10 );
|
||||
element.setTimer( 'bar', spy2, 20 );
|
||||
this.clock.tick( 100 );
|
||||
assert.ok( spy.called && spy2.called, 'Timeouts with different names do not conflict' );
|
||||
assert.strictEqual( spy.called && spy2.called, true, 'Timeouts with different names do not conflict' );
|
||||
|
||||
spy = this.sandbox.spy();
|
||||
spy2 = this.sandbox.spy();
|
||||
element.setTimer( 'foo', spy, 10 );
|
||||
element2.setTimer( 'foo', spy2, 20 );
|
||||
this.clock.tick( 100 );
|
||||
assert.ok( spy.called && spy2.called, 'Timeouts in different elements do not conflict' );
|
||||
assert.strictEqual( spy.called && spy2.called, true, 'Timeouts in different elements do not conflict' );
|
||||
|
||||
spy = this.sandbox.spy();
|
||||
element.setTimer( 'foo', spy, 10 );
|
||||
element.clearTimer( 'foo' );
|
||||
this.clock.tick( 100 );
|
||||
assert.ok( !spy.called, 'Timeout is invalidated by clearing' );
|
||||
assert.strictEqual( spy.called, false, 'Timeout is invalidated by clearing' );
|
||||
|
||||
spy = this.sandbox.spy();
|
||||
element.setTimer( 'foo', spy, 100 );
|
||||
this.clock.tick( 80 );
|
||||
element.resetTimer( 'foo' );
|
||||
this.clock.tick( 80 );
|
||||
assert.ok( !spy.called, 'Timeout is reset' );
|
||||
assert.strictEqual( spy.called, false, 'Timeout is reset' );
|
||||
this.clock.tick( 80 );
|
||||
assert.ok( spy.called, 'Timeout works after reset' );
|
||||
assert.strictEqual( spy.called, true, 'Timeout works after reset' );
|
||||
|
||||
spy = this.sandbox.spy();
|
||||
element.setTimer( 'foo', spy, 100 );
|
||||
this.clock.tick( 80 );
|
||||
element.resetTimer( 'foo', 200 );
|
||||
this.clock.tick( 180 );
|
||||
assert.ok( !spy.called, 'Timeout is reset to the designated delay' );
|
||||
assert.strictEqual( spy.called, false, 'Timeout is reset to the designated delay' );
|
||||
this.clock.tick( 80 );
|
||||
assert.ok( spy.called, 'Timeout works after changing the delay' );
|
||||
assert.strictEqual( spy.called, true, 'Timeout works after changing the delay' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'correctEW()', function ( assert ) {
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
$anchor = $( '<div>' ).appendTo( $qf ),
|
||||
dialog = new mw.mmv.ui.TipsyDialog( $anchor );
|
||||
|
||||
assert.ok( !$( '.mw-mmv-tipsy-dialog' ).length, 'dialog is not shown' );
|
||||
assert.notOk( $( '.mw-mmv-tipsy-dialog' ).length, 'dialog is not shown' );
|
||||
dialog.open();
|
||||
assert.ok( $( '.mw-mmv-tipsy-dialog' ).length, 'dialog is shown' );
|
||||
dialog.close();
|
||||
assert.ok( !$( '.mw-mmv-tipsy-dialog' ).length, 'dialog is not shown' );
|
||||
assert.notOk( $( '.mw-mmv-tipsy-dialog' ).length, 'dialog is not shown' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'setContent', function ( assert ) {
|
||||
|
@ -60,9 +60,9 @@
|
|||
dialog.getPopup().trigger( 'click' );
|
||||
assert.ok( $( '.mw-mmv-tipsy-dialog' ).length, 'dialog is not hidden when clicked' );
|
||||
dialog.getPopup().find( '.mw-mmv-tipsy-dialog-disable' ).trigger( 'click' );
|
||||
assert.ok( !$( '.mw-mmv-tipsy-dialog' ).length, 'dialog is hidden when close icon is clicked' );
|
||||
assert.notOk( $( '.mw-mmv-tipsy-dialog' ).length, 'dialog is hidden when close icon is clicked' );
|
||||
dialog.open();
|
||||
$qf.trigger( 'click' );
|
||||
assert.ok( !$( '.mw-mmv-tipsy-dialog' ).length, 'dialog is hidden when clicked outside' );
|
||||
assert.notOk( $( '.mw-mmv-tipsy-dialog' ).length, 'dialog is hidden when clicked outside' );
|
||||
} );
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
|
@ -73,15 +73,15 @@
|
|||
|
||||
$submitButton.trigger( 'click' );
|
||||
|
||||
assert.ok( !dialog.$disableConfirmation.hasClass( 'mw-mmv-shown' ), 'Disable confirmation not shown yet' );
|
||||
assert.ok( !dialog.$dialog.hasClass( 'mw-mmv-disable-confirmation-shown' ), 'Disable confirmation not shown yet' );
|
||||
assert.strictEqual( dialog.$disableConfirmation.hasClass( 'mw-mmv-shown' ), false, 'Disable confirmation not shown yet' );
|
||||
assert.strictEqual( dialog.$dialog.hasClass( 'mw-mmv-disable-confirmation-shown' ), false, 'Disable confirmation not shown yet' );
|
||||
|
||||
// Pretend that the async call in mmv.js succeeded
|
||||
deferred.resolve();
|
||||
|
||||
// The confirmation should appear
|
||||
assert.ok( dialog.$disableConfirmation.hasClass( 'mw-mmv-shown' ), 'Disable confirmation shown' );
|
||||
assert.ok( dialog.$dialog.hasClass( 'mw-mmv-disable-confirmation-shown' ), 'Disable confirmation shown' );
|
||||
assert.strictEqual( dialog.$disableConfirmation.hasClass( 'mw-mmv-shown' ), true, 'Disable confirmation shown' );
|
||||
assert.strictEqual( dialog.$dialog.hasClass( 'mw-mmv-disable-confirmation-shown' ), true, 'Disable confirmation shown' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Enable', function ( assert ) {
|
||||
|
@ -126,14 +126,14 @@
|
|||
|
||||
$submitButton.trigger( 'click' );
|
||||
|
||||
assert.ok( !dialog.$enableConfirmation.hasClass( 'mw-mmv-shown' ), 'Enable confirmation not shown yet' );
|
||||
assert.ok( !dialog.$dialog.hasClass( 'mw-mmv-enable-confirmation-shown' ), 'Enable confirmation not shown yet' );
|
||||
assert.strictEqual( dialog.$enableConfirmation.hasClass( 'mw-mmv-shown' ), false, 'Enable confirmation not shown yet' );
|
||||
assert.strictEqual( dialog.$dialog.hasClass( 'mw-mmv-enable-confirmation-shown' ), false, 'Enable confirmation not shown yet' );
|
||||
|
||||
// Pretend that the async call in mmv.js succeeded
|
||||
deferred.resolve();
|
||||
|
||||
// The confirmation should appear
|
||||
assert.ok( dialog.$enableConfirmation.hasClass( 'mw-mmv-shown' ), 'Enable confirmation shown' );
|
||||
assert.ok( dialog.$dialog.hasClass( 'mw-mmv-enable-confirmation-shown' ), 'Enable confirmation shown' );
|
||||
assert.strictEqual( dialog.$enableConfirmation.hasClass( 'mw-mmv-shown' ), true, 'Enable confirmation shown' );
|
||||
assert.strictEqual( dialog.$dialog.hasClass( 'mw-mmv-enable-confirmation-shown' ), true, 'Enable confirmation shown' );
|
||||
} );
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
Loading…
Reference in a new issue