mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-23 15:56:47 +00:00
build: Update eslint-config-wikimedia to 0.28.0 and autofix
Change-Id: Iff4b874580768b008427c0bea535ab08cea14a36
This commit is contained in:
parent
14f47a0509
commit
fa18975543
|
@ -2,8 +2,5 @@
|
|||
"root": true,
|
||||
"extends": [
|
||||
"wikimedia/server"
|
||||
],
|
||||
"rules": {
|
||||
"no-var": "error"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
1655
package-lock.json
generated
1655
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -9,7 +9,7 @@
|
|||
"doc": "jsdoc -c jsdoc.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint-config-wikimedia": "0.27.0",
|
||||
"eslint-config-wikimedia": "0.28.0",
|
||||
"grunt": "1.6.1",
|
||||
"grunt-banana-checker": "0.13.0",
|
||||
"grunt-eslint": "24.3.0",
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"max-len": "off",
|
||||
"no-jquery/no-class-state": "off",
|
||||
"no-jquery/no-support": "off",
|
||||
"es-x/no-resizable-and-growable-arraybuffers": "warn"
|
||||
"es-x/no-resizable-and-growable-arraybuffers": "off"
|
||||
},
|
||||
"settings": {
|
||||
"jsdoc": {
|
||||
|
|
|
@ -518,10 +518,10 @@ class MultimediaViewerBootstrap {
|
|||
if ( !$thumbCaption.length ) { // gallery, maybe
|
||||
$thumbCaption = $thumbContainer
|
||||
.closest( '.gallerybox' )
|
||||
.not( () => {
|
||||
.not(
|
||||
// do not treat categories as galleries - the autogenerated caption they have is not helpful
|
||||
return $thumbContainer.closest( '#mw-category-media' ).length;
|
||||
} )
|
||||
() => $thumbContainer.closest( '#mw-category-media' ).length
|
||||
)
|
||||
.not( () => {
|
||||
// do not treat special file related pages as galleries
|
||||
const $specialFileRelatedPages = $(
|
||||
|
|
|
@ -79,12 +79,11 @@ class Utils {
|
|||
*/
|
||||
static createSelectMenu( options, def ) {
|
||||
const $select = $( '<select>' ).addClass( 'cdx-select mw-mmv-flex-grow-1' );
|
||||
options.forEach( ( size ) =>
|
||||
$( '<option>' )
|
||||
.attr( 'value', size )
|
||||
.data( 'name', size )
|
||||
.text( Utils.getDimensionsMessageHtml( size ) )
|
||||
.appendTo( $select )
|
||||
options.forEach( ( size ) => $( '<option>' )
|
||||
.attr( 'value', size )
|
||||
.data( 'name', size )
|
||||
.text( Utils.getDimensionsMessageHtml( size ) )
|
||||
.appendTo( $select )
|
||||
);
|
||||
$select.val( def );
|
||||
return $select;
|
||||
|
|
|
@ -328,8 +328,7 @@ class MultimediaViewer {
|
|||
return;
|
||||
}
|
||||
|
||||
const thumb = this.thumbs.find( ( t ) =>
|
||||
t.filePageTitle.getPrefixedText() === title.getPrefixedText() &&
|
||||
const thumb = this.thumbs.find( ( t ) => t.filePageTitle.getPrefixedText() === title.getPrefixedText() &&
|
||||
( !position || t.position === position )
|
||||
);
|
||||
|
||||
|
@ -554,9 +553,7 @@ class MultimediaViewer {
|
|||
preloadImagesMetadata() {
|
||||
this.cancelImageMetadataPreloading();
|
||||
|
||||
this.metadataPreloadQueue = this.pushLightboxImagesIntoQueue( ( lightboxImage ) => {
|
||||
return () => this.fetchSizeIndependentLightboxInfo( lightboxImage.filePageTitle );
|
||||
} );
|
||||
this.metadataPreloadQueue = this.pushLightboxImagesIntoQueue( ( lightboxImage ) => () => this.fetchSizeIndependentLightboxInfo( lightboxImage.filePageTitle ) );
|
||||
|
||||
this.metadataPreloadQueue.execute();
|
||||
}
|
||||
|
@ -569,18 +566,16 @@ class MultimediaViewer {
|
|||
preloadThumbnails() {
|
||||
this.cancelThumbnailsPreloading();
|
||||
|
||||
this.thumbnailPreloadQueue = this.pushLightboxImagesIntoQueue( ( lightboxImage ) => {
|
||||
return () => {
|
||||
// viewer.ui.canvas.getLightboxImageWidths needs the viewer to be open
|
||||
// because it needs to read the size of visible elements
|
||||
if ( !this.isOpen ) {
|
||||
return;
|
||||
}
|
||||
this.thumbnailPreloadQueue = this.pushLightboxImagesIntoQueue( ( lightboxImage ) => () => {
|
||||
// viewer.ui.canvas.getLightboxImageWidths needs the viewer to be open
|
||||
// because it needs to read the size of visible elements
|
||||
if ( !this.isOpen ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const imageWidths = this.ui.canvas.getLightboxImageWidths( lightboxImage );
|
||||
const imageWidths = this.ui.canvas.getLightboxImageWidths( lightboxImage );
|
||||
|
||||
return this.fetchThumbnailForLightboxImage( lightboxImage, imageWidths.real );
|
||||
};
|
||||
return this.fetchThumbnailForLightboxImage( lightboxImage, imageWidths.real );
|
||||
} );
|
||||
|
||||
this.thumbnailPreloadQueue.execute();
|
||||
|
|
|
@ -91,28 +91,24 @@ class ImageInfo extends Api {
|
|||
* @return {jQuery.Promise} a promise which resolves to an Image object.
|
||||
*/
|
||||
get( file ) {
|
||||
return this.getCachedPromise( file.getPrefixedDb(), () => {
|
||||
return this.apiGetWithMaxAge( {
|
||||
formatversion: 2,
|
||||
action: 'query',
|
||||
prop: 'imageinfo',
|
||||
titles: file.getPrefixedDb(),
|
||||
iiprop: this.iiprop,
|
||||
iiextmetadatafilter: this.iiextmetadatafilter,
|
||||
iiextmetadatalanguage: this.options.language,
|
||||
uselang: 'content'
|
||||
} ).then( ( data ) => {
|
||||
return this.getQueryPage( data );
|
||||
} ).then( ( page ) => {
|
||||
if ( page.imageinfo && page.imageinfo.length ) {
|
||||
return ImageModel.newFromImageInfo( file, page );
|
||||
} else if ( page.missing === true && page.imagerepository === '' ) {
|
||||
return $.Deferred().reject( `file does not exist: ${ file.getPrefixedDb() }` );
|
||||
} else {
|
||||
return $.Deferred().reject( 'unknown error' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
return this.getCachedPromise( file.getPrefixedDb(), () => this.apiGetWithMaxAge( {
|
||||
formatversion: 2,
|
||||
action: 'query',
|
||||
prop: 'imageinfo',
|
||||
titles: file.getPrefixedDb(),
|
||||
iiprop: this.iiprop,
|
||||
iiextmetadatafilter: this.iiextmetadatafilter,
|
||||
iiextmetadatalanguage: this.options.language,
|
||||
uselang: 'content'
|
||||
} ).then( ( data ) => this.getQueryPage( data ) ).then( ( page ) => {
|
||||
if ( page.imageinfo && page.imageinfo.length ) {
|
||||
return ImageModel.newFromImageInfo( file, page );
|
||||
} else if ( page.missing === true && page.imagerepository === '' ) {
|
||||
return $.Deferred().reject( `file does not exist: ${ file.getPrefixedDb() }` );
|
||||
} else {
|
||||
return $.Deferred().reject( 'unknown error' );
|
||||
}
|
||||
} ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,39 +49,35 @@ class ThumbnailInfo extends Api {
|
|||
get( file, width, height ) {
|
||||
const cacheKey = `${ file.getPrefixedDb() }|${ width || '' }|${ height || '' }`;
|
||||
|
||||
return this.getCachedPromise( cacheKey, () => {
|
||||
return this.apiGetWithMaxAge( {
|
||||
formatversion: 2,
|
||||
action: 'query',
|
||||
prop: 'imageinfo',
|
||||
titles: file.getPrefixedDb(),
|
||||
iiprop: 'url',
|
||||
iiurlwidth: width,
|
||||
iiurlheight: height
|
||||
} ).then( ( data ) => {
|
||||
return this.getQueryPage( data );
|
||||
} ).then( ( page ) => {
|
||||
let imageInfo;
|
||||
if ( page.imageinfo && page.imageinfo[ 0 ] ) {
|
||||
imageInfo = page.imageinfo[ 0 ];
|
||||
if ( imageInfo.thumburl && imageInfo.thumbwidth && imageInfo.thumbheight ) {
|
||||
return $.Deferred().resolve(
|
||||
new Thumbnail(
|
||||
imageInfo.thumburl,
|
||||
imageInfo.thumbwidth,
|
||||
imageInfo.thumbheight
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return $.Deferred().reject( 'error in provider, thumb info not found' );
|
||||
}
|
||||
} else if ( page.missing === true && page.imagerepository === '' ) {
|
||||
return $.Deferred().reject( `file does not exist: ${ file.getPrefixedDb() }` );
|
||||
return this.getCachedPromise( cacheKey, () => this.apiGetWithMaxAge( {
|
||||
formatversion: 2,
|
||||
action: 'query',
|
||||
prop: 'imageinfo',
|
||||
titles: file.getPrefixedDb(),
|
||||
iiprop: 'url',
|
||||
iiurlwidth: width,
|
||||
iiurlheight: height
|
||||
} ).then( ( data ) => this.getQueryPage( data ) ).then( ( page ) => {
|
||||
let imageInfo;
|
||||
if ( page.imageinfo && page.imageinfo[ 0 ] ) {
|
||||
imageInfo = page.imageinfo[ 0 ];
|
||||
if ( imageInfo.thumburl && imageInfo.thumbwidth && imageInfo.thumbheight ) {
|
||||
return $.Deferred().resolve(
|
||||
new Thumbnail(
|
||||
imageInfo.thumburl,
|
||||
imageInfo.thumbwidth,
|
||||
imageInfo.thumbheight
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return $.Deferred().reject( 'unknown error' );
|
||||
return $.Deferred().reject( 'error in provider, thumb info not found' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} else if ( page.missing === true && page.imagerepository === '' ) {
|
||||
return $.Deferred().reject( `file does not exist: ${ file.getPrefixedDb() }` );
|
||||
} else {
|
||||
return $.Deferred().reject( 'unknown error' );
|
||||
}
|
||||
} ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
"rules": {
|
||||
"no-jquery/no-global-selector": "off",
|
||||
"no-jquery/no-sizzle": "off",
|
||||
"es-x/no-resizable-and-growable-arraybuffers": "warn"
|
||||
"es-x/no-resizable-and-growable-arraybuffers": "off"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ const { createLocalStorage, getDisabledLocalStorage, getFakeLocalStorage, getUns
|
|||
( function () {
|
||||
QUnit.module( 'mmv.Config', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Constructor sense test', function ( assert ) {
|
||||
QUnit.test( 'Constructor sense test', ( assert ) => {
|
||||
const config = new Config( {}, {}, {}, {}, null );
|
||||
assert.true( config instanceof Config );
|
||||
} );
|
||||
|
|
|
@ -39,12 +39,12 @@ const { EmbedFileFormatter } = require( 'mmv.ui.reuse' );
|
|||
};
|
||||
}
|
||||
|
||||
QUnit.test( 'EmbedFileFormatter constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'EmbedFileFormatter constructor sense check', ( assert ) => {
|
||||
const formatter = new EmbedFileFormatter();
|
||||
assert.true( formatter instanceof EmbedFileFormatter, 'constructor with no argument works' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getByline():', function ( assert ) {
|
||||
QUnit.test( 'getByline():', ( assert ) => {
|
||||
const formatter = new EmbedFileFormatter();
|
||||
const author = '<span class="mw-mmv-author">Homer</span>';
|
||||
const source = '<span class="mw-mmv-source">Iliad</span>';
|
||||
|
@ -71,7 +71,7 @@ const { EmbedFileFormatter } = require( 'mmv.ui.reuse' );
|
|||
assert.strictEqual( byline, '<span class="mw-mmv-source">Iliad</span>', 'Source found in bylines.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getThumbnailHtml():', function ( assert ) {
|
||||
QUnit.test( 'getThumbnailHtml():', ( assert ) => {
|
||||
const formatter = new EmbedFileFormatter();
|
||||
const titleText = 'Music Room';
|
||||
const title = mw.Title.newFromText( titleText );
|
||||
|
@ -162,7 +162,7 @@ const { EmbedFileFormatter } = require( 'mmv.ui.reuse' );
|
|||
|
||||
} );
|
||||
|
||||
QUnit.test( 'getThumbnailWikitext():', function ( assert ) {
|
||||
QUnit.test( 'getThumbnailWikitext():', ( assert ) => {
|
||||
const formatter = new EmbedFileFormatter();
|
||||
const title = mw.Title.newFromText( 'File:Foobar.jpg' );
|
||||
const imgUrl = 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg';
|
||||
|
|
|
@ -22,7 +22,7 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
|
||||
QUnit.module( 'mmv.HtmlUtils', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'wrapAndJquerify() for single node', function ( assert ) {
|
||||
QUnit.test( 'wrapAndJquerify() for single node', ( assert ) => {
|
||||
const $el = $( '<span>' );
|
||||
const el = $( '<span>' ).get( 0 );
|
||||
const html = '<span></span>';
|
||||
|
@ -32,12 +32,12 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
assert.strictEqual( HtmlUtils.wrapAndJquerify( el ).html(), '<span></span>', 'HTMLElement' );
|
||||
assert.strictEqual( HtmlUtils.wrapAndJquerify( html ).html(), '<span></span>', 'HTML string' );
|
||||
|
||||
assert.throws( function () {
|
||||
assert.throws( () => {
|
||||
HtmlUtils.wrapAndJquerify( invalid );
|
||||
}, 'throws exception for invalid type' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'wrapAndJquerify() for multiple nodes', function ( assert ) {
|
||||
QUnit.test( 'wrapAndJquerify() for multiple nodes', ( assert ) => {
|
||||
const $el = $( '<span></span><span></span>' );
|
||||
const html = '<span></span><span></span>';
|
||||
|
||||
|
@ -45,7 +45,7 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
assert.strictEqual( HtmlUtils.wrapAndJquerify( html ).html(), '<span></span><span></span>', 'HTML string' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'wrapAndJquerify() for text', function ( assert ) {
|
||||
QUnit.test( 'wrapAndJquerify() for text', ( assert ) => {
|
||||
const $el = $( document.createTextNode( 'foo' ) );
|
||||
const html = 'foo';
|
||||
|
||||
|
@ -53,7 +53,7 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
assert.strictEqual( HtmlUtils.wrapAndJquerify( html ).html(), 'foo', 'HTML string' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'wrapAndJquerify() does not change original', function ( assert ) {
|
||||
QUnit.test( 'wrapAndJquerify() does not change original', ( assert ) => {
|
||||
const $el = $( '<span>' );
|
||||
const el = $( '<span>' ).get( 0 );
|
||||
|
||||
|
@ -63,7 +63,7 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
assert.strictEqual( $( el ).data( 'x' ), undefined, 'wrapped HTMLElement is not the same as original' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'filterInvisible()', function ( assert ) {
|
||||
QUnit.test( 'filterInvisible()', ( assert ) => {
|
||||
const $visibleChild = $( '<div><span></span></div>' );
|
||||
const $invisibleChild = $( '<div><span style="display: none"></span></div>' );
|
||||
const $styleChild = $( '<div><style></style></div>' );
|
||||
|
@ -91,7 +91,7 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
assert.strictEqual( $invisibleChildWithVisibleSiblings.has( 'b' ).length, 1, '...but its visible siblings are not' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'whitelistHtml()', function ( assert ) {
|
||||
QUnit.test( 'whitelistHtml()', ( assert ) => {
|
||||
const $whitelisted = $( '<div>abc<a>def</a>ghi</div>' );
|
||||
const $nonWhitelisted = $( '<div>abc<span>def</span>ghi</div>' );
|
||||
const $nonWhitelistedInWhitelisted = $( '<div>abc<a>d<span>e</span>f</a>ghi</div>' );
|
||||
|
@ -114,7 +114,7 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
assert.strictEqual( $siblings.has( 'a' ).length, 1, 'Whitelisted siblings are kept.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'appendWhitespaceToBlockElements()', function ( assert ) {
|
||||
QUnit.test( 'appendWhitespaceToBlockElements()', ( assert ) => {
|
||||
const $noBlockElement = $( '<div>abc<i>def</i>ghi</div>' );
|
||||
const $blockElement = $( '<div>abc<p>def</p>ghi</div>' );
|
||||
const $linebreak = $( '<div>abc<br>def</div>' );
|
||||
|
@ -128,7 +128,7 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
assert.true( /abc\s+def/.test( $linebreak.text() ), 'Linebreaks are whitespaced.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'jqueryToHtml()', function ( assert ) {
|
||||
QUnit.test( 'jqueryToHtml()', ( assert ) => {
|
||||
|
||||
assert.strictEqual( HtmlUtils.jqueryToHtml( $( '<a>' ) ), '<a></a>',
|
||||
'works for single element' );
|
||||
|
@ -138,7 +138,7 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
'works for text nodes' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'mergeWhitespace()', function ( assert ) {
|
||||
QUnit.test( 'mergeWhitespace()', ( assert ) => {
|
||||
assert.strictEqual( HtmlUtils.mergeWhitespace( ' x \n' ), 'x',
|
||||
'leading/trainling whitespace is trimmed' );
|
||||
assert.strictEqual( HtmlUtils.mergeWhitespace( 'x \n\n \n y' ), 'x\ny',
|
||||
|
@ -147,31 +147,31 @@ const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|||
'multiple spaces are collapsed into a single one' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'htmlToText()', function ( assert ) {
|
||||
QUnit.test( 'htmlToText()', ( assert ) => {
|
||||
const html = '<table><tr><td>Foo</td><td><a>bar</a></td><td style="display: none">baz</td></tr></table>';
|
||||
|
||||
assert.strictEqual( HtmlUtils.htmlToText( html ), 'Foo bar', 'works' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'htmlToTextWithLinks()', function ( assert ) {
|
||||
QUnit.test( 'htmlToTextWithLinks()', ( assert ) => {
|
||||
const html = '<table><tr><td><b>F</b>o<i>o</i></td><td><a>bar</a></td><td style="display: none">baz</td></tr></table>';
|
||||
|
||||
assert.strictEqual( HtmlUtils.htmlToTextWithLinks( html ), 'Foo <a>bar</a>', 'works' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'htmlToTextWithTags()', function ( assert ) {
|
||||
QUnit.test( 'htmlToTextWithTags()', ( assert ) => {
|
||||
const html = '<table><tr><td><b>F</b>o<i>o</i><sub>o</sub><sup>o</sup></td><td><a>bar</a></td><td style="display: none">baz</td></tr></table>';
|
||||
|
||||
assert.strictEqual( HtmlUtils.htmlToTextWithTags( html ), '<b>F</b>o<i>o</i><sub>o</sub><sup>o</sup> <a>bar</a>', 'works' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'isJQueryOrHTMLElement()', function ( assert ) {
|
||||
QUnit.test( 'isJQueryOrHTMLElement()', ( assert ) => {
|
||||
assert.strictEqual( HtmlUtils.isJQueryOrHTMLElement( $( '<span>' ) ), true, 'Recognizes jQuery objects correctly' );
|
||||
assert.strictEqual( HtmlUtils.isJQueryOrHTMLElement( $( '<span>' ).get( 0 ) ), true, 'Recognizes HTMLElements correctly' );
|
||||
assert.strictEqual( HtmlUtils.isJQueryOrHTMLElement( '<span></span>' ), false, 'Doesn\'t recognize HTML string' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'makeLinkText()', function ( assert ) {
|
||||
QUnit.test( 'makeLinkText()', ( assert ) => {
|
||||
assert.strictEqual( HtmlUtils.makeLinkText( 'foo', {
|
||||
href: 'http://example.com',
|
||||
title: 'h<b>t</b><i>m</i>l'
|
||||
|
|
|
@ -3,7 +3,7 @@ const { ThumbnailWidthCalculator } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.ThumbnailWidthCalculator', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'ThumbnailWidthCalculator constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'ThumbnailWidthCalculator constructor sense check', ( assert ) => {
|
||||
const badWidthBuckets = [];
|
||||
const goodWidthBuckets = [ 1 ];
|
||||
|
||||
|
@ -18,14 +18,14 @@ const { ThumbnailWidthCalculator } = require( 'mmv' );
|
|||
} );
|
||||
assert.true( thumbnailWidthCalculator instanceof ThumbnailWidthCalculator, 'constructor with non-default buckets works' );
|
||||
|
||||
assert.throws( function () {
|
||||
assert.throws( () => {
|
||||
thumbnailWidthCalculator = new ThumbnailWidthCalculator( {
|
||||
widthBuckets: badWidthBuckets
|
||||
} );
|
||||
}, 'constructor with empty bucket list throws exception' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'findNextBucket() test', function ( assert ) {
|
||||
QUnit.test( 'findNextBucket() test', ( assert ) => {
|
||||
const thumbnailWidthCalculator = new ThumbnailWidthCalculator( {
|
||||
widthBuckets: [ 100, 200 ]
|
||||
} );
|
||||
|
@ -44,7 +44,7 @@ const { ThumbnailWidthCalculator } = require( 'mmv' );
|
|||
} );
|
||||
|
||||
// Old tests for the default bucket sizes. Preserved because why not.
|
||||
QUnit.test( 'We get sensible image sizes when we ask for them', function ( assert ) {
|
||||
QUnit.test( 'We get sensible image sizes when we ask for them', ( assert ) => {
|
||||
const twc = new ThumbnailWidthCalculator();
|
||||
|
||||
assert.strictEqual( twc.findNextBucket( 200 ), 320, 'Low target size gives us lowest possible size bucket' );
|
||||
|
@ -54,7 +54,7 @@ const { ThumbnailWidthCalculator } = require( 'mmv' );
|
|||
assert.strictEqual( twc.findNextBucket( 3000 ), 2880, 'The image bucketing also works on REALLY big screens' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'findNextBucket() test with unordered bucket list', function ( assert ) {
|
||||
QUnit.test( 'findNextBucket() test with unordered bucket list', ( assert ) => {
|
||||
const thumbnailWidthCalculator = new ThumbnailWidthCalculator( {
|
||||
widthBuckets: [ 200, 100 ]
|
||||
} );
|
||||
|
@ -69,7 +69,7 @@ const { ThumbnailWidthCalculator } = require( 'mmv' );
|
|||
'return next bucket for value between two buckets' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'calculateFittingWidth() test', function ( assert ) {
|
||||
QUnit.test( 'calculateFittingWidth() test', ( assert ) => {
|
||||
const boundingWidth = 100;
|
||||
const boundingHeight = 200;
|
||||
const thumbnailWidthCalculator = new ThumbnailWidthCalculator( { widthBuckets: [ 1 ] } );
|
||||
|
@ -90,7 +90,7 @@ const { ThumbnailWidthCalculator } = require( 'mmv' );
|
|||
100, 'fit calculation correct when same aspect ratio' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'calculateWidths() test', function ( assert ) {
|
||||
QUnit.test( 'calculateWidths() test', ( assert ) => {
|
||||
const boundingWidth = 100;
|
||||
const boundingHeight = 200;
|
||||
const thumbnailWidthCalculator = new ThumbnailWidthCalculator( {
|
||||
|
@ -117,7 +117,7 @@ const { ThumbnailWidthCalculator } = require( 'mmv' );
|
|||
assert.strictEqual( widths.real, 128, 'real width is correct when same aspect ratio' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'calculateWidths() test with non-standard device pixel ratio', function ( assert ) {
|
||||
QUnit.test( 'calculateWidths() test with non-standard device pixel ratio', ( assert ) => {
|
||||
const boundingWidth = 100;
|
||||
const boundingHeight = 200;
|
||||
const thumbnailWidthCalculator = new ThumbnailWidthCalculator( {
|
||||
|
|
|
@ -148,11 +148,11 @@ const { asyncMethod, waitForAsync, getMultimediaViewer } = require( './mmv.testh
|
|||
// use setTimeout to add new hash change to end of the call stack,
|
||||
// ensuring that event handlers for our previous change can execute
|
||||
// without us interfering with another immediate change
|
||||
setTimeout( function () {
|
||||
setTimeout( () => {
|
||||
location.hash = hash;
|
||||
} );
|
||||
|
||||
return waitForAsync().then( function () {
|
||||
return waitForAsync().then( () => {
|
||||
assert.strictEqual( callCount, 1, 'Viewer should be loaded once' );
|
||||
bootstrap.cleanupEventHandlers();
|
||||
location.hash = '';
|
||||
|
@ -171,7 +171,7 @@ const { asyncMethod, waitForAsync, getMultimediaViewer } = require( './mmv.testh
|
|||
this.sandbox.stub( bootstrap, 'setupOverlay' );
|
||||
this.sandbox.stub( bootstrap, 'cleanupOverlay' );
|
||||
|
||||
bootstrap.loadViewer( true ).fail( function ( message ) {
|
||||
bootstrap.loadViewer( true ).fail( ( message ) => {
|
||||
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' );
|
||||
|
@ -402,7 +402,7 @@ const { asyncMethod, waitForAsync, getMultimediaViewer } = require( './mmv.testh
|
|||
clock.reset();
|
||||
} );
|
||||
|
||||
QUnit.test( 'Only load the viewer on a valid hash', function ( assert ) {
|
||||
QUnit.test( 'Only load the viewer on a valid hash', ( assert ) => {
|
||||
location.hash = '';
|
||||
|
||||
const bootstrap = createBootstrap();
|
||||
|
@ -410,7 +410,7 @@ const { asyncMethod, waitForAsync, getMultimediaViewer } = require( './mmv.testh
|
|||
return hashTest( '/media', bootstrap, assert );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Load the viewer on a legacy hash', function ( assert ) {
|
||||
QUnit.test( 'Load the viewer on a legacy hash', ( assert ) => {
|
||||
location.hash = '';
|
||||
|
||||
const bootstrap = createBootstrap();
|
||||
|
@ -466,7 +466,7 @@ const { asyncMethod, waitForAsync, getMultimediaViewer } = require( './mmv.testh
|
|||
bootstrap.cleanupOverlay();
|
||||
|
||||
// Scroll restoration is on a setTimeout
|
||||
setTimeout( function () {
|
||||
setTimeout( () => {
|
||||
assert.strictEqual( $( window ).scrollTop(), 50, 'Scroll is correctly reset to original top position' );
|
||||
done();
|
||||
} );
|
||||
|
@ -499,7 +499,7 @@ const { asyncMethod, waitForAsync, getMultimediaViewer } = require( './mmv.testh
|
|||
clock.restore();
|
||||
} );
|
||||
|
||||
QUnit.test( 'isAllowedThumb', function ( assert ) {
|
||||
QUnit.test( 'isAllowedThumb', ( assert ) => {
|
||||
const $container = $( '<div>' );
|
||||
const $thumb = $( '<img>' ).appendTo( $container );
|
||||
const bootstrap = createBootstrap();
|
||||
|
@ -519,7 +519,7 @@ const { asyncMethod, waitForAsync, getMultimediaViewer } = require( './mmv.testh
|
|||
assert.strictEqual( bootstrap.isAllowedThumb( $thumb ), false, 'Image with a noviewer class is disallowed.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'findCaption', function ( assert ) {
|
||||
QUnit.test( 'findCaption', ( assert ) => {
|
||||
const gallery = createGallery( 'foo.jpg', 'Baz' );
|
||||
const thumb = createThumb( 'foo.jpg', 'Quuuuux' );
|
||||
const link = createNormal( 'foo.jpg', 'Foobar' );
|
||||
|
|
|
@ -2,7 +2,7 @@ const { LightboxImage } = require( 'mmv.bootstrap' );
|
|||
|
||||
QUnit.module( 'mmv.lightboximage', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Sense test', function ( assert ) {
|
||||
QUnit.test( 'Sense test', ( assert ) => {
|
||||
const lightboxImage = new LightboxImage( 'foo.png' );
|
||||
|
||||
assert.true( lightboxImage instanceof LightboxImage, 'Object created' );
|
||||
|
|
|
@ -22,7 +22,7 @@ const { getMultimediaViewer } = require( './mmv.testhelpers.js' );
|
|||
}
|
||||
} ) );
|
||||
|
||||
QUnit.test( 'Sense test, object creation and ui construction', function ( assert ) {
|
||||
QUnit.test( 'Sense test, object creation and ui construction', ( assert ) => {
|
||||
const lightbox = new LightboxInterface();
|
||||
|
||||
stubScrollTo();
|
||||
|
@ -82,7 +82,7 @@ const { getMultimediaViewer } = require( './mmv.testhelpers.js' );
|
|||
clock.restore();
|
||||
} );
|
||||
|
||||
QUnit.test( 'Fullscreen mode init', function ( assert ) {
|
||||
QUnit.test( 'Fullscreen mode init', ( assert ) => {
|
||||
const lightbox = new LightboxInterface();
|
||||
const enterFullscreen = Element.prototype.requestFullscreen;
|
||||
|
||||
|
@ -134,7 +134,7 @@ const { getMultimediaViewer } = require( './mmv.testhelpers.js' );
|
|||
restoreScrollTo();
|
||||
} );
|
||||
|
||||
QUnit.test( 'Fullscreen mode', function ( assert ) {
|
||||
QUnit.test( 'Fullscreen mode', ( assert ) => {
|
||||
const lightbox = new LightboxInterface();
|
||||
const viewer = getMultimediaViewer();
|
||||
const enterFullscreen = Element.prototype.requestFullscreen;
|
||||
|
@ -213,7 +213,7 @@ const { getMultimediaViewer } = require( './mmv.testhelpers.js' );
|
|||
restoreScrollTo();
|
||||
} );
|
||||
|
||||
QUnit.test( 'isAnyActiveButtonHovered', function ( assert ) {
|
||||
QUnit.test( 'isAnyActiveButtonHovered', ( assert ) => {
|
||||
const lightbox = new LightboxInterface();
|
||||
|
||||
stubScrollTo();
|
||||
|
@ -254,7 +254,7 @@ const { getMultimediaViewer } = require( './mmv.testhelpers.js' );
|
|||
restoreScrollTo();
|
||||
} );
|
||||
|
||||
QUnit.test( 'Keyboard prev/next', function ( assert ) {
|
||||
QUnit.test( 'Keyboard prev/next', ( assert ) => {
|
||||
const viewer = getMultimediaViewer();
|
||||
const lightbox = new LightboxInterface();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ const { MultimediaViewerBootstrap } = require( 'mmv.bootstrap' );
|
|||
}
|
||||
} ) );
|
||||
|
||||
QUnit.test( 'eachPreloadableLightboxIndex()', function ( assert ) {
|
||||
QUnit.test( 'eachPreloadableLightboxIndex()', ( assert ) => {
|
||||
const viewer = getMultimediaViewer();
|
||||
let expectedIndices;
|
||||
let i;
|
||||
|
@ -26,14 +26,14 @@ const { MultimediaViewerBootstrap } = require( 'mmv.bootstrap' );
|
|||
viewer.currentIndex = 2;
|
||||
i = 0;
|
||||
expectedIndices = [ 2, 3, 1, 4, 0, 5 ];
|
||||
viewer.eachPreloadableLightboxIndex( function ( index ) {
|
||||
viewer.eachPreloadableLightboxIndex( ( index ) => {
|
||||
assert.strictEqual( index, expectedIndices[ i++ ], 'preload on left edge' );
|
||||
} );
|
||||
|
||||
viewer.currentIndex = 9;
|
||||
i = 0;
|
||||
expectedIndices = [ 9, 10, 8, 7, 6 ];
|
||||
viewer.eachPreloadableLightboxIndex( function ( index ) {
|
||||
viewer.eachPreloadableLightboxIndex( ( index ) => {
|
||||
assert.strictEqual( index, expectedIndices[ i++ ], 'preload on right edge' );
|
||||
} );
|
||||
} );
|
||||
|
@ -222,7 +222,7 @@ const { MultimediaViewerBootstrap } = require( 'mmv.bootstrap' );
|
|||
viewer.close();
|
||||
} );
|
||||
|
||||
QUnit.test( 'resetThumbnailStates', function ( assert ) {
|
||||
QUnit.test( 'resetThumbnailStates', ( assert ) => {
|
||||
const viewer = getMultimediaViewer();
|
||||
|
||||
assert.strictEqual( viewer.realThumbnailShown, false, 'Real thumbnail state is correct' );
|
||||
|
@ -273,7 +273,7 @@ const { MultimediaViewerBootstrap } = require( 'mmv.bootstrap' );
|
|||
assert.strictEqual( viewer.realThumbnailShown, true, 'Real thumbnail state is correct' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Real thumbnail first, then placeholder', function ( assert ) {
|
||||
QUnit.test( 'Real thumbnail first, then placeholder', ( assert ) => {
|
||||
const viewer = getMultimediaViewer();
|
||||
|
||||
viewer.setImage = function () {};
|
||||
|
@ -454,7 +454,7 @@ const { MultimediaViewerBootstrap } = require( 'mmv.bootstrap' );
|
|||
}
|
||||
} );
|
||||
|
||||
QUnit.test( 'Refuse to load too-big thumbnails', function ( assert ) {
|
||||
QUnit.test( 'Refuse to load too-big thumbnails', ( assert ) => {
|
||||
let expectedWidth;
|
||||
const reuestedWidth = 1000;
|
||||
const originalWidth = 50;
|
||||
|
|
|
@ -151,7 +151,7 @@ const { MultimediaViewer } = require( 'mmv' );
|
|||
setTimeout( deferred.resolve );
|
||||
|
||||
return QUnit.whenPromisesComplete.apply( null, MTH.asyncPromises ).then(
|
||||
function () {
|
||||
() => {
|
||||
MTH.asyncPromises = [];
|
||||
}
|
||||
);
|
||||
|
|
|
@ -20,7 +20,7 @@ const { ImageModel, License } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.model.Image', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Image model constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'Image model constructor sense check', ( assert ) => {
|
||||
const title = mw.Title.newFromText( 'File:Foobar.jpg' );
|
||||
const name = 'Foo bar';
|
||||
const size = 100;
|
||||
|
@ -79,7 +79,7 @@ const { ImageModel, License } = require( 'mmv' );
|
|||
assert.true( $.isPlainObject( imageData.thumbUrls ), 'Thumb URL cache is set up properly' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'hasCoords()', function ( assert ) {
|
||||
QUnit.test( 'hasCoords()', ( assert ) => {
|
||||
const firstImageData = new ImageModel(
|
||||
mw.Title.newFromText( 'File:Foobar.pdf.jpg' ), 'Foo bar',
|
||||
10, 10, 10, 'image/jpeg', 'http://example.org', 'http://example.com', 42,
|
||||
|
@ -98,7 +98,7 @@ const { ImageModel, License } = require( 'mmv' );
|
|||
assert.strictEqual( secondImageData.hasCoords(), true, 'Coordinates present means hasCoords returns true.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'parseExtmeta()', function ( assert ) {
|
||||
QUnit.test( 'parseExtmeta()', ( assert ) => {
|
||||
const stringData = { value: 'foo' };
|
||||
const plaintextData = { value: 'fo<b>o</b>' };
|
||||
const integerData = { value: 3 };
|
||||
|
@ -147,7 +147,7 @@ const { ImageModel, License } = require( 'mmv' );
|
|||
assert.strictEqual( ImageModel.parseExtmeta( { value: '1926<div style="display: none;">date QS:P571,+1926-00-00T00:00:00Z/9</div>' }, 'datetime' ), '1926',
|
||||
'Extmeta year is extracted from hidden div.' );
|
||||
|
||||
assert.throws( function () {
|
||||
assert.throws( () => {
|
||||
ImageModel.parseExtmeta( stringData, 'strong' );
|
||||
}, 'Exception is thrown on invalid argument' );
|
||||
} );
|
||||
|
|
|
@ -20,7 +20,7 @@ const { IwTitle } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.model.IwTitle', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'constructor sense test', function ( assert ) {
|
||||
QUnit.test( 'constructor sense test', ( assert ) => {
|
||||
const namespace = 4;
|
||||
const fullPageName = 'User_talk:John_Doe';
|
||||
const domain = 'en.wikipedia.org';
|
||||
|
@ -30,7 +30,7 @@ const { IwTitle } = require( 'mmv' );
|
|||
assert.true( title instanceof IwTitle );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getters', function ( assert ) {
|
||||
QUnit.test( 'getters', ( assert ) => {
|
||||
const namespace = 4;
|
||||
const fullPageName = 'User_talk:John_Doe';
|
||||
const domain = 'en.wikipedia.org';
|
||||
|
|
|
@ -21,7 +21,7 @@ const { License } = require( 'mmv' );
|
|||
|
||||
QUnit.module( 'mmv.model.License', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'License constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'License constructor sense check', ( assert ) => {
|
||||
const shortName = 'CC-BY-SA-3.0';
|
||||
const internalName = 'cc-by-sa-3.0';
|
||||
const longName = 'Creative Commons Attribution--Share-Alike 3.0';
|
||||
|
@ -41,12 +41,12 @@ const { License } = require( 'mmv' );
|
|||
assert.strictEqual( license.longName, longName, 'License has correct long name' );
|
||||
assert.strictEqual( license.deedUrl, url, 'License has correct deed URL' );
|
||||
|
||||
assert.throws( function () {
|
||||
assert.throws( () => {
|
||||
license = new License();
|
||||
}, 'License cannot be created without a short name' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getShortName()', function ( assert ) {
|
||||
QUnit.test( 'getShortName()', ( assert ) => {
|
||||
const existingMessageKey = 'Internal name that does exist';
|
||||
const nonExistingMessageKey = 'Internal name that does not exist';
|
||||
const license1 = new License( 'Shortname' );
|
||||
|
@ -78,7 +78,7 @@ const { License } = require( 'mmv' );
|
|||
mw.messages.exists = oldMwMessagesExists;
|
||||
} );
|
||||
|
||||
QUnit.test( 'getShortLink()', function ( assert ) {
|
||||
QUnit.test( 'getShortLink()', ( assert ) => {
|
||||
const license1 = new License( 'lorem ipsum' );
|
||||
const license2 = new License( 'lorem ipsum', 'lipsum' );
|
||||
const license3 = new License( 'lorem ipsum', 'lipsum', 'Lorem ipsum dolor sit amet' );
|
||||
|
@ -101,7 +101,7 @@ const { License } = require( 'mmv' );
|
|||
'Title for license with link is formatted correctly' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'isCc()', function ( assert ) {
|
||||
QUnit.test( 'isCc()', ( assert ) => {
|
||||
let license = new License( 'CC-BY-SA-2.0', 'cc-by-sa-2.0',
|
||||
'Creative Commons Attribution - ShareAlike 2.0',
|
||||
'http://creativecommons.org/licenses/by-sa/2.0/' );
|
||||
|
@ -115,7 +115,7 @@ const { License } = require( 'mmv' );
|
|||
assert.strictEqual( license.isCc(), false, 'Non-CC license with no internal name not recognized' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'isPd()', function ( assert ) {
|
||||
QUnit.test( 'isPd()', ( assert ) => {
|
||||
let license = new License( 'Public Domain', 'pd',
|
||||
'Public Domain for lack of originality' );
|
||||
assert.strictEqual( license.isPd(), true, 'PD license recognized' );
|
||||
|
@ -129,7 +129,7 @@ const { License } = require( 'mmv' );
|
|||
assert.strictEqual( license.isPd(), false, 'Non-PD license with no internal name not recognized' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'isFree()', function ( assert ) {
|
||||
QUnit.test( 'isFree()', ( assert ) => {
|
||||
let license = new License( 'CC-BY-SA-2.0', 'cc-by-sa-2.0',
|
||||
'Creative Commons Attribution - ShareAlike 2.0',
|
||||
'http://creativecommons.org/licenses/by-sa/2.0/' );
|
||||
|
@ -140,7 +140,7 @@ const { License } = require( 'mmv' );
|
|||
assert.strictEqual( license.isFree(), false, 'Non-free flag handled correctly' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'needsAttribution()', function ( assert ) {
|
||||
QUnit.test( 'needsAttribution()', ( assert ) => {
|
||||
let license = new License( 'CC-BY-SA-2.0', 'cc-by-sa-2.0',
|
||||
'Creative Commons Attribution - ShareAlike 2.0',
|
||||
'http://creativecommons.org/licenses/by-sa/2.0/' );
|
||||
|
|
|
@ -20,7 +20,7 @@ const { Repo, ForeignApiRepo, ForeignDbRepo } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.model.Repo', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Repo constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'Repo constructor sense check', ( assert ) => {
|
||||
const displayName = 'Wikimedia Commons';
|
||||
const favicon = '//commons.wikimedia.org/favicon.ico';
|
||||
const apiUrl = '//commons.wikimedia.org/w/api.php';
|
||||
|
@ -38,7 +38,7 @@ const { Repo, ForeignApiRepo, ForeignDbRepo } = require( 'mmv' );
|
|||
assert.true( foreignDbRepo instanceof ForeignDbRepo, 'Foreign DB repo creation works' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getArticlePath()', function ( assert ) {
|
||||
QUnit.test( 'getArticlePath()', ( assert ) => {
|
||||
const displayName = 'Wikimedia Commons';
|
||||
const favicon = '//commons.wikimedia.org/favicon.ico';
|
||||
const apiUrl = '//commons.wikimedia.org/w/api.php';
|
||||
|
@ -70,7 +70,7 @@ const { Repo, ForeignApiRepo, ForeignDbRepo } = require( 'mmv' );
|
|||
mw.config.set( 'wgServer', oldWgServer );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getSiteLink()', function ( assert ) {
|
||||
QUnit.test( 'getSiteLink()', ( assert ) => {
|
||||
const displayName = 'Wikimedia Commons';
|
||||
const favicon = '//commons.wikimedia.org/favicon.ico';
|
||||
const apiUrl = '//commons.wikimedia.org/w/api.php';
|
||||
|
|
|
@ -20,23 +20,23 @@ const { TaskQueue } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.model.TaskQueue', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'TaskQueue constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'TaskQueue constructor sense check', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
|
||||
assert.true( taskQueue instanceof TaskQueue, 'TaskQueue created successfully' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Queue length check', function ( assert ) {
|
||||
QUnit.test( 'Queue length check', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
|
||||
assert.strictEqual( taskQueue.queue.length, 0, 'queue is initially empty' );
|
||||
|
||||
taskQueue.push( function () {} );
|
||||
taskQueue.push( () => {} );
|
||||
|
||||
assert.strictEqual( taskQueue.queue.length, 1, 'queue length is incremented on push' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'State check', function ( assert ) {
|
||||
QUnit.test( 'State check', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
const task = $.Deferred();
|
||||
|
||||
|
@ -45,7 +45,7 @@ const { TaskQueue } = require( 'mmv' );
|
|||
assert.strictEqual( taskQueue.state, TaskQueue.State.NOT_STARTED,
|
||||
'state is initially NOT_STARTED' );
|
||||
|
||||
const promise = taskQueue.execute().then( function () {
|
||||
const promise = taskQueue.execute().then( () => {
|
||||
assert.strictEqual( taskQueue.state, TaskQueue.State.FINISHED,
|
||||
'state is FINISHED after execution finished' );
|
||||
} );
|
||||
|
@ -58,7 +58,7 @@ const { TaskQueue } = require( 'mmv' );
|
|||
return promise;
|
||||
} );
|
||||
|
||||
QUnit.test( 'State check for cancellation', function ( assert ) {
|
||||
QUnit.test( 'State check for cancellation', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
const task = $.Deferred();
|
||||
|
||||
|
@ -70,118 +70,114 @@ const { TaskQueue } = require( 'mmv' );
|
|||
'state is CANCELLED after cancellation' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Test executing empty queue', function ( assert ) {
|
||||
QUnit.test( 'Test executing empty queue', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
|
||||
return taskQueue.execute().done( function () {
|
||||
return taskQueue.execute().done( () => {
|
||||
assert.true( true, 'Queue promise resolved' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Simple execution test', function ( assert ) {
|
||||
QUnit.test( 'Simple execution test', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
let called = false;
|
||||
|
||||
taskQueue.push( function () {
|
||||
taskQueue.push( () => {
|
||||
called = true;
|
||||
} );
|
||||
|
||||
return taskQueue.execute().then( function () {
|
||||
return taskQueue.execute().then( () => {
|
||||
assert.strictEqual( called, true, 'Task executed successfully' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Task execution order test', function ( assert ) {
|
||||
QUnit.test( 'Task execution order test', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
const order = [];
|
||||
|
||||
taskQueue.push( function () {
|
||||
taskQueue.push( () => {
|
||||
order.push( 1 );
|
||||
} );
|
||||
|
||||
taskQueue.push( function () {
|
||||
taskQueue.push( () => {
|
||||
const deferred = $.Deferred();
|
||||
|
||||
order.push( 2 );
|
||||
|
||||
setTimeout( function () {
|
||||
setTimeout( () => {
|
||||
deferred.resolve();
|
||||
}, 0 );
|
||||
|
||||
return deferred;
|
||||
} );
|
||||
|
||||
taskQueue.push( function () {
|
||||
taskQueue.push( () => {
|
||||
order.push( 3 );
|
||||
} );
|
||||
|
||||
return taskQueue.execute().then( function () {
|
||||
return taskQueue.execute().then( () => {
|
||||
assert.deepEqual( order, [ 1, 2, 3 ], 'Tasks executed in order' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Double execution test', function ( assert ) {
|
||||
QUnit.test( 'Double execution test', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
let called = 0;
|
||||
|
||||
taskQueue.push( function () {
|
||||
taskQueue.push( () => {
|
||||
called++;
|
||||
} );
|
||||
|
||||
return taskQueue.execute().then( function () {
|
||||
return taskQueue.execute();
|
||||
} ).then( function () {
|
||||
return taskQueue.execute().then( () => taskQueue.execute() ).then( () => {
|
||||
assert.strictEqual( called, 1, 'Task executed only once' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Parallel execution test', function ( assert ) {
|
||||
QUnit.test( 'Parallel execution test', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
let called = 0;
|
||||
|
||||
taskQueue.push( function () {
|
||||
taskQueue.push( () => {
|
||||
called++;
|
||||
} );
|
||||
|
||||
return $.when(
|
||||
taskQueue.execute(),
|
||||
taskQueue.execute()
|
||||
).then( function () {
|
||||
).then( () => {
|
||||
assert.strictEqual( called, 1, 'Task executed only once' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Test push after execute', function ( assert ) {
|
||||
QUnit.test( 'Test push after execute', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
|
||||
taskQueue.execute();
|
||||
|
||||
assert.throws( function () {
|
||||
taskQueue.push( function () {} );
|
||||
assert.throws( () => {
|
||||
taskQueue.push( () => {} );
|
||||
}, 'Exception thrown when trying to push to an already running queue' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Test failed task', function ( assert ) {
|
||||
QUnit.test( 'Test failed task', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
|
||||
taskQueue.push( function () {
|
||||
return $.Deferred().reject();
|
||||
} );
|
||||
taskQueue.push( () => $.Deferred().reject() );
|
||||
|
||||
return taskQueue.execute().done( function () {
|
||||
return taskQueue.execute().done( () => {
|
||||
assert.true( true, 'Queue promise resolved' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Test that tasks wait for each other', function ( assert ) {
|
||||
QUnit.test( 'Test that tasks wait for each other', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
let longRunningTaskFinished = false;
|
||||
let seenFinished = false;
|
||||
|
||||
taskQueue.push( function () {
|
||||
taskQueue.push( () => {
|
||||
const deferred = $.Deferred();
|
||||
|
||||
setTimeout( function () {
|
||||
setTimeout( () => {
|
||||
longRunningTaskFinished = true;
|
||||
deferred.resolve();
|
||||
}, 0 );
|
||||
|
@ -189,16 +185,16 @@ const { TaskQueue } = require( 'mmv' );
|
|||
return deferred;
|
||||
} );
|
||||
|
||||
taskQueue.push( function () {
|
||||
taskQueue.push( () => {
|
||||
seenFinished = longRunningTaskFinished;
|
||||
} );
|
||||
|
||||
return taskQueue.execute().then( function () {
|
||||
return taskQueue.execute().then( () => {
|
||||
assert.true( seenFinished, 'Task waits for previous task to finish' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Test cancellation before start', function ( assert ) {
|
||||
QUnit.test( 'Test cancellation before start', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
let triggered = false;
|
||||
const verificationTask = function () {
|
||||
|
@ -210,40 +206,40 @@ const { TaskQueue } = require( 'mmv' );
|
|||
taskQueue.cancel();
|
||||
|
||||
taskQueue.execute()
|
||||
.done( function () {
|
||||
.done( () => {
|
||||
assert.true( false, 'Queue promise rejected' );
|
||||
} )
|
||||
.fail( function () {
|
||||
.fail( () => {
|
||||
assert.true( true, 'Queue promise rejected' );
|
||||
assert.strictEqual( triggered, false, 'Task was not triggered' );
|
||||
} )
|
||||
.always( assert.async() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Test cancellation within callback', function ( assert ) {
|
||||
QUnit.test( 'Test cancellation within callback', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
let triggered = false;
|
||||
const verificationTask = function () {
|
||||
triggered = true;
|
||||
};
|
||||
|
||||
taskQueue.push( function () {
|
||||
taskQueue.push( () => {
|
||||
taskQueue.cancel();
|
||||
} );
|
||||
taskQueue.push( verificationTask );
|
||||
|
||||
taskQueue.execute()
|
||||
.done( function () {
|
||||
.done( () => {
|
||||
assert.true( false, 'Queue promise rejected' );
|
||||
} )
|
||||
.fail( function () {
|
||||
.fail( () => {
|
||||
assert.true( true, 'Queue promise rejected' );
|
||||
assert.strictEqual( triggered, false, 'Task was not triggered' );
|
||||
} )
|
||||
.always( assert.async() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Test cancellation from task', function ( assert ) {
|
||||
QUnit.test( 'Test cancellation from task', ( assert ) => {
|
||||
const taskQueue = new TaskQueue();
|
||||
let triggered = false;
|
||||
const task1 = $.Deferred();
|
||||
|
@ -251,21 +247,19 @@ const { TaskQueue } = require( 'mmv' );
|
|||
triggered = true;
|
||||
};
|
||||
|
||||
taskQueue.push( function () {
|
||||
return task1;
|
||||
} );
|
||||
taskQueue.push( () => task1 );
|
||||
taskQueue.push( verificationTask );
|
||||
|
||||
setTimeout( function () {
|
||||
setTimeout( () => {
|
||||
taskQueue.cancel();
|
||||
task1.resolve();
|
||||
}, 0 );
|
||||
|
||||
taskQueue.execute()
|
||||
.done( function () {
|
||||
.done( () => {
|
||||
assert.true( false, 'Queue promise rejected' );
|
||||
} )
|
||||
.fail( function () {
|
||||
.fail( () => {
|
||||
assert.true( true, 'Queue promise rejected' );
|
||||
assert.strictEqual( triggered, false, 'Task was not triggered' );
|
||||
} )
|
||||
|
|
|
@ -20,7 +20,7 @@ const { Thumbnail, ThumbnailWidth } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.model', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Thumbnail constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'Thumbnail constructor sense check', ( assert ) => {
|
||||
const width = 23;
|
||||
const height = 42;
|
||||
const url = 'http://example.com/foo.jpg';
|
||||
|
@ -30,12 +30,12 @@ const { Thumbnail, ThumbnailWidth } = require( 'mmv' );
|
|||
assert.strictEqual( thumbnail.width, width, 'Width is set correctly' );
|
||||
assert.strictEqual( thumbnail.height, height, 'Height is set correctly' );
|
||||
|
||||
assert.throws( function () {
|
||||
assert.throws( () => {
|
||||
thumbnail = new Thumbnail( url, width );
|
||||
}, 'Exception is thrown when parameters are missing' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ThumbnailWidth constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'ThumbnailWidth constructor sense check', ( assert ) => {
|
||||
const cssWidth = 23;
|
||||
const cssHeight = 29;
|
||||
const screenWidth = 42;
|
||||
|
@ -48,7 +48,7 @@ const { Thumbnail, ThumbnailWidth } = require( 'mmv' );
|
|||
assert.strictEqual( thumbnailWidth.screen, screenWidth, 'Screen width is set correctly' );
|
||||
assert.strictEqual( thumbnailWidth.real, realWidth, 'Real width is set correctly' );
|
||||
|
||||
assert.throws( function () {
|
||||
assert.throws( () => {
|
||||
thumbnailWidth = new ThumbnailWidth( cssWidth, screenWidth );
|
||||
}, 'Exception is thrown when parameters are missing' );
|
||||
} );
|
||||
|
|
|
@ -20,7 +20,7 @@ const { Api } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.provider.Api', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Api constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'Api constructor sense check', ( assert ) => {
|
||||
const api = { get: function () {} };
|
||||
const options = {};
|
||||
const apiProvider = new Api( api, options );
|
||||
|
@ -59,7 +59,7 @@ const { Api } = require( 'mmv' );
|
|||
assert.false( 'smaxage' in api.get.getCall( 0 ).args[ 0 ], 'smaxage can be overridden to unset' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getCachedPromise success', function ( assert ) {
|
||||
QUnit.test( 'getCachedPromise success', ( assert ) => {
|
||||
const api = { get: function () {} };
|
||||
const apiProvider = new Api( api );
|
||||
const oldMwLog = mw.log;
|
||||
|
@ -76,23 +76,23 @@ const { Api } = require( 'mmv' );
|
|||
};
|
||||
};
|
||||
|
||||
apiProvider.getCachedPromise( 'foo', promiseSource( 1 ) ).done( function ( result ) {
|
||||
apiProvider.getCachedPromise( 'foo', promiseSource( 1 ) ).done( ( result ) => {
|
||||
assert.strictEqual( result, 1, 'result comes from the promise source' );
|
||||
} );
|
||||
|
||||
apiProvider.getCachedPromise( 'bar', promiseSource( 2 ) ).done( function ( result ) {
|
||||
apiProvider.getCachedPromise( 'bar', promiseSource( 2 ) ).done( ( result ) => {
|
||||
assert.strictEqual( result, 2, 'result comes from the promise source' );
|
||||
} );
|
||||
|
||||
promiseShouldBeCached = true;
|
||||
apiProvider.getCachedPromise( 'foo', promiseSource( 3 ) ).done( function ( result ) {
|
||||
apiProvider.getCachedPromise( 'foo', promiseSource( 3 ) ).done( ( result ) => {
|
||||
assert.strictEqual( result, 1, 'result comes from cache' );
|
||||
} );
|
||||
|
||||
mw.log = oldMwLog;
|
||||
} );
|
||||
|
||||
QUnit.test( 'getCachedPromise failure', function ( assert ) {
|
||||
QUnit.test( 'getCachedPromise failure', ( assert ) => {
|
||||
const api = { get: function () {} };
|
||||
const apiProvider = new Api( api );
|
||||
const oldMwLog = mw.log;
|
||||
|
@ -109,23 +109,23 @@ const { Api } = require( 'mmv' );
|
|||
};
|
||||
};
|
||||
|
||||
apiProvider.getCachedPromise( 'foo', promiseSource( 1 ) ).fail( function ( result ) {
|
||||
apiProvider.getCachedPromise( 'foo', promiseSource( 1 ) ).fail( ( result ) => {
|
||||
assert.strictEqual( result, 1, 'result comes from the promise source' );
|
||||
} );
|
||||
|
||||
apiProvider.getCachedPromise( 'bar', promiseSource( 2 ) ).fail( function ( result ) {
|
||||
apiProvider.getCachedPromise( 'bar', promiseSource( 2 ) ).fail( ( result ) => {
|
||||
assert.strictEqual( result, 2, 'result comes from the promise source' );
|
||||
} );
|
||||
|
||||
promiseShouldBeCached = true;
|
||||
apiProvider.getCachedPromise( 'foo', promiseSource( 3 ) ).fail( function ( result ) {
|
||||
apiProvider.getCachedPromise( 'foo', promiseSource( 3 ) ).fail( ( result ) => {
|
||||
assert.strictEqual( result, 1, 'result comes from cache' );
|
||||
} );
|
||||
|
||||
mw.log = oldMwLog;
|
||||
} );
|
||||
|
||||
QUnit.test( 'getErrorMessage', function ( assert ) {
|
||||
QUnit.test( 'getErrorMessage', ( assert ) => {
|
||||
const api = { get: function () {} };
|
||||
const apiProvider = new Api( api );
|
||||
|
||||
|
@ -143,7 +143,7 @@ const { Api } = require( 'mmv' );
|
|||
assert.strictEqual( apiProvider.getErrorMessage( {} ), 'unknown error', 'missing error message is handled' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getQueryPage', function ( assert ) {
|
||||
QUnit.test( 'getQueryPage', ( assert ) => {
|
||||
const api = { get: function () {} };
|
||||
const apiProvider = new Api( api );
|
||||
const done = assert.async( 5 );
|
||||
|
@ -158,22 +158,22 @@ const { Api } = require( 'mmv' );
|
|||
}
|
||||
};
|
||||
|
||||
apiProvider.getQueryPage( data ).then( function ( field ) {
|
||||
apiProvider.getQueryPage( data ).then( ( field ) => {
|
||||
assert.strictEqual( field, data.query.pages[ 0 ], 'specified page is found' );
|
||||
done();
|
||||
} );
|
||||
|
||||
apiProvider.getQueryPage( {} ).fail( function () {
|
||||
apiProvider.getQueryPage( {} ).fail( () => {
|
||||
assert.true( true, 'promise rejected when data is missing' );
|
||||
done();
|
||||
} );
|
||||
|
||||
apiProvider.getQueryPage( { data: { query: {} } } ).fail( function () {
|
||||
apiProvider.getQueryPage( { data: { query: {} } } ).fail( () => {
|
||||
assert.true( true, 'promise rejected when pages are missing' );
|
||||
done();
|
||||
} );
|
||||
|
||||
apiProvider.getQueryPage( { data: { query: { pages: [] } } } ).fail( function () {
|
||||
apiProvider.getQueryPage( { data: { query: { pages: [] } } } ).fail( () => {
|
||||
assert.true( true, 'promise rejected when pages are empty' );
|
||||
done();
|
||||
} );
|
||||
|
@ -189,7 +189,7 @@ const { Api } = require( 'mmv' );
|
|||
}
|
||||
]
|
||||
}
|
||||
} ).fail( function () {
|
||||
} ).fail( () => {
|
||||
assert.true( true, 'promise rejected when data contains two entries' );
|
||||
done();
|
||||
} );
|
||||
|
|
|
@ -20,12 +20,12 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.provider.GuessedThumbnailInfo', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'Constructor sense check', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
assert.true( provider instanceof GuessedThumbnailInfo, 'Constructor call successful' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'get()', function ( assert ) {
|
||||
QUnit.test( 'get()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
const file = new mw.Title( 'File:Copyleft.svg' );
|
||||
const sampleUrl = 'http://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Copyleft.svg/180px-Copyleft.svg.png';
|
||||
|
@ -39,7 +39,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
let result = provider.get( file, sampleUrl, width, originalWidth, originalHeight );
|
||||
assert.true( typeof result.then === 'function', 'Result is a promise' );
|
||||
assert.strictEqual( result.state(), 'resolved', 'Result is resolved' );
|
||||
result.then( function ( thumbnailInfo ) {
|
||||
result.then( ( thumbnailInfo ) => {
|
||||
assert.true( typeof thumbnailInfo.width === 'number', 'Width is set' );
|
||||
assert.true( typeof thumbnailInfo.height === 'number', 'Height is set' );
|
||||
assert.strictEqual( thumbnailInfo.url, resultUrl, 'URL is set' );
|
||||
|
@ -52,7 +52,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
assert.strictEqual( result.state(), 'rejected', 'Result is rejected' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getUrl()', function ( assert ) {
|
||||
QUnit.test( 'getUrl()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
let file = new mw.Title( 'File:Elizabeth_I_George_Gower.jpg' );
|
||||
let originalWidth = 922;
|
||||
|
@ -101,7 +101,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
assert.strictEqual( resultUrl, expectedUrl, 'Thumbnail to "full-size", image with unlimited size' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'needsOriginal()', function ( assert ) {
|
||||
QUnit.test( 'needsOriginal()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
let file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
|
@ -116,7 +116,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
assert.strictEqual( provider.needsOriginal( file, 2000, 1000 ), true, 'Thumbnail of a PNG bigger than the original size needs original' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'isFullSizeUrl()', function ( assert ) {
|
||||
QUnit.test( 'isFullSizeUrl()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
const file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
|
@ -128,7 +128,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
'Original url recognized as being full size' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'obscureFilename()', function ( assert ) {
|
||||
QUnit.test( 'obscureFilename()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
let file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
|
@ -141,7 +141,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
'http://upload.wikimedia.org/wikipedia/commons/thumb/d/da/<filename>/180px-<filename>', 'Filename with urlencoded character correctly obscured' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'restoreFilename()', function ( assert ) {
|
||||
QUnit.test( 'restoreFilename()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
const file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
|
@ -150,7 +150,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
|
||||
} );
|
||||
|
||||
QUnit.test( 'canHaveLargerThumbnailThanOriginal()', function ( assert ) {
|
||||
QUnit.test( 'canHaveLargerThumbnailThanOriginal()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
let file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
|
@ -177,7 +177,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
assert.strictEqual( provider.canHaveLargerThumbnailThanOriginal( file ), false, 'GIF can\'t have a larger thumbnail than the original' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'canBeDisplayedInBrowser()', function ( assert ) {
|
||||
QUnit.test( 'canBeDisplayedInBrowser()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
let file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
|
@ -204,7 +204,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
assert.strictEqual( provider.canBeDisplayedInBrowser( file ), true, 'GIF can be displayed as-is in the browser' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'guessWidth()', function ( assert ) {
|
||||
QUnit.test( 'guessWidth()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
let file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
|
@ -217,7 +217,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
assert.strictEqual( provider.guessWidth( file, 2000, 1000 ), 1000, 'Width correctly guessed for JPG thumbnail bigger than the original' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'guessHeight()', function ( assert ) {
|
||||
QUnit.test( 'guessHeight()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
let file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
|
@ -230,7 +230,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
assert.strictEqual( provider.guessHeight( file, 2000, 1000, 500 ), 500, 'Height correctly guessed for JPG thumbnail bigger than the original' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'replaceSize()', function ( assert ) {
|
||||
QUnit.test( 'replaceSize()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
let file = new mw.Title( 'File:Copyleft.svg' );
|
||||
|
||||
|
@ -250,7 +250,7 @@ const { GuessedThumbnailInfo } = require( 'mmv' );
|
|||
'https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Ranunculus_gmelinii_NRCS-2.tiff/lossy-page1-220px-Ranunculus_gmelinii_NRCS-2.tiff.jpg', 'Works with extra parameters' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'guessFullUrl()', function ( assert ) {
|
||||
QUnit.test( 'guessFullUrl()', ( assert ) => {
|
||||
const provider = new GuessedThumbnailInfo();
|
||||
let file = new mw.Title( 'File:Copyleft.svg' );
|
||||
let fullUrl = 'http://upload.wikimedia.org/wikipedia/commons/8/8b/Copyleft.svg';
|
||||
|
|
|
@ -20,13 +20,13 @@ const { ImageProvider } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.provider.Image', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Image constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'Image constructor sense check', ( assert ) => {
|
||||
const imageProvider = new ImageProvider();
|
||||
|
||||
assert.true( imageProvider instanceof ImageProvider );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Image load success', function ( assert ) {
|
||||
QUnit.test( 'Image load success', ( assert ) => {
|
||||
const url = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0' +
|
||||
'iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH' +
|
||||
'8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC';
|
||||
|
@ -34,14 +34,14 @@ const { ImageProvider } = require( 'mmv' );
|
|||
|
||||
imageProvider.imagePreloadingSupported = () => false;
|
||||
|
||||
return imageProvider.get( url ).then( function ( image ) {
|
||||
return imageProvider.get( url ).then( ( image ) => {
|
||||
assert.true( image instanceof HTMLImageElement,
|
||||
'success handler was called with the image element' );
|
||||
assert.strictEqual( image.src, url, 'image src is correct' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Image caching', function ( assert ) {
|
||||
QUnit.test( 'Image caching', ( assert ) => {
|
||||
const url = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0' +
|
||||
'iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH' +
|
||||
'8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC';
|
||||
|
@ -52,26 +52,26 @@ const { ImageProvider } = require( 'mmv' );
|
|||
imageProvider.imagePreloadingSupported = () => false;
|
||||
|
||||
return QUnit.whenPromisesComplete(
|
||||
imageProvider.get( url ).then( function ( image ) {
|
||||
imageProvider.get( url ).then( ( image ) => {
|
||||
result = image;
|
||||
assert.true( image instanceof HTMLImageElement,
|
||||
'success handler was called with the image element' );
|
||||
assert.strictEqual( image.src, url, 'image src is correct' );
|
||||
} ),
|
||||
|
||||
imageProvider.get( url ).then( function ( image ) {
|
||||
imageProvider.get( url ).then( ( image ) => {
|
||||
assert.strictEqual( image, result, 'image element is cached and not regenerated' );
|
||||
assert.strictEqual( image.src, url, 'image src is correct' );
|
||||
} ),
|
||||
|
||||
imageProvider.get( url2 ).then( function ( image ) {
|
||||
imageProvider.get( url2 ).then( ( image ) => {
|
||||
assert.notStrictEqual( image, result, 'image element for different url is not cached' );
|
||||
assert.strictEqual( image.src, url2, 'image src is correct' );
|
||||
} )
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( 'Image load fail', function ( assert ) {
|
||||
QUnit.test( 'Image load fail', ( assert ) => {
|
||||
const imageProvider = new ImageProvider();
|
||||
const oldMwLog = mw.log;
|
||||
const done = assert.async();
|
||||
|
@ -82,7 +82,7 @@ const { ImageProvider } = require( 'mmv' );
|
|||
mwLogCalled = true;
|
||||
};
|
||||
|
||||
imageProvider.get( 'doesntexist.png' ).fail( function () {
|
||||
imageProvider.get( 'doesntexist.png' ).fail( () => {
|
||||
assert.true( true, 'fail handler was called' );
|
||||
assert.true( mwLogCalled, 'mw.log was called' );
|
||||
mw.log = oldMwLog;
|
||||
|
@ -90,7 +90,7 @@ const { ImageProvider } = require( 'mmv' );
|
|||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Image load with preloading supported', function ( assert ) {
|
||||
QUnit.test( 'Image load with preloading supported', ( assert ) => {
|
||||
const url = mw.config.get( 'wgExtensionAssetsPath' ) + '/MultimediaViewer/resources/mmv.ui.restriction/img/restrict-personality.svg';
|
||||
const imageProvider = new ImageProvider();
|
||||
const endsWith = function ( a, b ) {
|
||||
|
@ -104,13 +104,13 @@ const { ImageProvider } = require( 'mmv' );
|
|||
}
|
||||
};
|
||||
|
||||
return imageProvider.get( url ).then( function ( image ) {
|
||||
return imageProvider.get( url ).then( ( image ) => {
|
||||
// can't test equality as browsers transform this to a full URL
|
||||
assert.true( endsWith( image.src, url ), 'local image loaded with correct source' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Failed image load with preloading supported', function ( assert ) {
|
||||
QUnit.test( 'Failed image load with preloading supported', ( assert ) => {
|
||||
const url = 'nosuchimage.png';
|
||||
const imageProvider = new ImageProvider();
|
||||
const done = assert.async();
|
||||
|
@ -122,13 +122,13 @@ const { ImageProvider } = require( 'mmv' );
|
|||
}
|
||||
};
|
||||
|
||||
imageProvider.get( url ).fail( function () {
|
||||
imageProvider.get( url ).fail( () => {
|
||||
assert.true( true, 'Fail callback called for non-existing image' );
|
||||
done();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'imageQueryParameter', function ( assert ) {
|
||||
QUnit.test( 'imageQueryParameter', ( assert ) => {
|
||||
const imageProvider = new ImageProvider( 'foo' );
|
||||
const done = assert.async();
|
||||
|
||||
|
@ -139,7 +139,7 @@ const { ImageProvider } = require( 'mmv' );
|
|||
return $.Deferred().resolve();
|
||||
};
|
||||
|
||||
imageProvider.get( 'http://www.wikipedia.org/' ).then( function () {
|
||||
imageProvider.get( 'http://www.wikipedia.org/' ).then( () => {
|
||||
done();
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -77,14 +77,14 @@ const { ImageInfo } = require( 'mmv' );
|
|||
}
|
||||
} ) );
|
||||
|
||||
QUnit.test( 'ImageInfo constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'ImageInfo constructor sense check', ( assert ) => {
|
||||
const api = { get: function () {} };
|
||||
const imageInfoProvider = new ImageInfo( api );
|
||||
|
||||
assert.true( imageInfoProvider instanceof ImageInfo );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ImageInfo get test', function ( assert ) {
|
||||
QUnit.test( 'ImageInfo get test', ( assert ) => {
|
||||
let apiCallCount = 0;
|
||||
const api = { get: function () {
|
||||
apiCallCount++;
|
||||
|
@ -200,7 +200,7 @@ const { ImageInfo } = require( 'mmv' );
|
|||
const file = new mw.Title( 'File:Stuff.jpg' );
|
||||
const imageInfoProvider = new ImageInfo( api );
|
||||
|
||||
return imageInfoProvider.get( file ).then( function ( image ) {
|
||||
return imageInfoProvider.get( file ).then( ( image ) => {
|
||||
assert.strictEqual( image.title.getPrefixedDb(), 'File:Stuff.jpg', 'title is set correctly' );
|
||||
assert.strictEqual( image.name, 'Some stuff', 'name is set correctly' );
|
||||
assert.strictEqual( image.size, 346684, 'size is set correctly' );
|
||||
|
@ -229,15 +229,15 @@ const { ImageInfo } = require( 'mmv' );
|
|||
assert.strictEqual( image.latitude, 90, 'latitude is set correctly' );
|
||||
assert.strictEqual( image.longitude, 180, 'longitude is set correctly' );
|
||||
assert.deepEqual( image.restrictions, [ 'trademarked', 'insignia' ], 'restrictions is set correctly' );
|
||||
} ).then( function () {
|
||||
} ).then(
|
||||
// call the data provider a second time to check caching
|
||||
return imageInfoProvider.get( file );
|
||||
} ).then( function () {
|
||||
() => imageInfoProvider.get( file )
|
||||
).then( () => {
|
||||
assert.strictEqual( apiCallCount, 1 );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ImageInfo fail test', function ( assert ) {
|
||||
QUnit.test( 'ImageInfo fail test', ( assert ) => {
|
||||
const api = { get: function () {
|
||||
return $.Deferred().resolve( {} );
|
||||
} };
|
||||
|
@ -245,13 +245,13 @@ const { ImageInfo } = require( 'mmv' );
|
|||
const done = assert.async();
|
||||
const imageInfoProvider = new ImageInfo( api );
|
||||
|
||||
imageInfoProvider.get( file ).fail( function () {
|
||||
imageInfoProvider.get( file ).fail( () => {
|
||||
assert.true( true, 'promise rejected when no data is returned' );
|
||||
done();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ImageInfo fail test 2', function ( assert ) {
|
||||
QUnit.test( 'ImageInfo fail test 2', ( assert ) => {
|
||||
const api = { get: function () {
|
||||
return $.Deferred().resolve( {
|
||||
query: {
|
||||
|
@ -267,13 +267,13 @@ const { ImageInfo } = require( 'mmv' );
|
|||
const done = assert.async();
|
||||
const imageInfoProvider = new ImageInfo( api );
|
||||
|
||||
imageInfoProvider.get( file ).fail( function () {
|
||||
imageInfoProvider.get( file ).fail( () => {
|
||||
assert.true( true, 'promise rejected when imageinfo is missing' );
|
||||
done();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ImageInfo missing page test', function ( assert ) {
|
||||
QUnit.test( 'ImageInfo missing page test', ( assert ) => {
|
||||
const api = { get: function () {
|
||||
return $.Deferred().resolve( {
|
||||
query: {
|
||||
|
@ -291,7 +291,7 @@ const { ImageInfo } = require( 'mmv' );
|
|||
const done = assert.async();
|
||||
const imageInfoProvider = new ImageInfo( api );
|
||||
|
||||
imageInfoProvider.get( file ).fail( function ( errorMessage ) {
|
||||
imageInfoProvider.get( file ).fail( ( errorMessage ) => {
|
||||
assert.strictEqual( errorMessage, 'file does not exist: File:Stuff.jpg',
|
||||
'error message is set correctly for missing file' );
|
||||
done();
|
||||
|
|
|
@ -77,14 +77,14 @@ const { ThumbnailInfo } = require( 'mmv' );
|
|||
}
|
||||
} ) );
|
||||
|
||||
QUnit.test( 'ThumbnailInfo constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'ThumbnailInfo constructor sense check', ( assert ) => {
|
||||
const api = { get: function () {} };
|
||||
const thumbnailInfoProvider = new ThumbnailInfo( api );
|
||||
|
||||
assert.true( thumbnailInfoProvider instanceof ThumbnailInfo );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ThumbnailInfo get test', function ( assert ) {
|
||||
QUnit.test( 'ThumbnailInfo get test', ( assert ) => {
|
||||
let apiCallCount = 0;
|
||||
const api = { get: function () {
|
||||
apiCallCount++;
|
||||
|
@ -113,30 +113,30 @@ const { ThumbnailInfo } = require( 'mmv' );
|
|||
const file = new mw.Title( 'File:Stuff.jpg' );
|
||||
const thumbnailInfoProvider = new ThumbnailInfo( api );
|
||||
|
||||
return thumbnailInfoProvider.get( file, 100 ).then( function ( thumbnail ) {
|
||||
return thumbnailInfoProvider.get( file, 100 ).then( ( thumbnail ) => {
|
||||
assert.strictEqual( thumbnail.url,
|
||||
'https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Stuff.jpg/51px-Stuff.jpg',
|
||||
'URL is set correctly' );
|
||||
assert.strictEqual( thumbnail.width, 95, 'actual width is set correctly' );
|
||||
assert.strictEqual( thumbnail.height, 200, 'actual height is set correctly' );
|
||||
} ).then( function () {
|
||||
} ).then( () => {
|
||||
assert.strictEqual( apiCallCount, 1 );
|
||||
// call the data provider a second time to check caching
|
||||
return thumbnailInfoProvider.get( file, 100 );
|
||||
} ).then( function () {
|
||||
} ).then( () => {
|
||||
assert.strictEqual( apiCallCount, 1 );
|
||||
// call a third time with different size to check caching
|
||||
return thumbnailInfoProvider.get( file, 110 );
|
||||
} ).then( function () {
|
||||
} ).then( () => {
|
||||
assert.strictEqual( apiCallCount, 2 );
|
||||
// call it again, with a height specified, to check caching
|
||||
return thumbnailInfoProvider.get( file, 110, 100 );
|
||||
} ).then( function () {
|
||||
} ).then( () => {
|
||||
assert.strictEqual( apiCallCount, 3 );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ThumbnailInfo fail test', function ( assert ) {
|
||||
QUnit.test( 'ThumbnailInfo fail test', ( assert ) => {
|
||||
const api = { get: function () {
|
||||
return $.Deferred().resolve( {} );
|
||||
} };
|
||||
|
@ -144,13 +144,13 @@ const { ThumbnailInfo } = require( 'mmv' );
|
|||
const done = assert.async();
|
||||
const thumbnailInfoProvider = new ThumbnailInfo( api );
|
||||
|
||||
thumbnailInfoProvider.get( file, 100 ).fail( function () {
|
||||
thumbnailInfoProvider.get( file, 100 ).fail( () => {
|
||||
assert.true( true, 'promise rejected when no data is returned' );
|
||||
done();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ThumbnailInfo fail test 2', function ( assert ) {
|
||||
QUnit.test( 'ThumbnailInfo fail test 2', ( assert ) => {
|
||||
const api = { get: function () {
|
||||
return $.Deferred().resolve( {
|
||||
query: {
|
||||
|
@ -166,13 +166,13 @@ const { ThumbnailInfo } = require( 'mmv' );
|
|||
const done = assert.async();
|
||||
const thumbnailInfoProvider = new ThumbnailInfo( api );
|
||||
|
||||
thumbnailInfoProvider.get( file, 100 ).fail( function () {
|
||||
thumbnailInfoProvider.get( file, 100 ).fail( () => {
|
||||
assert.true( true, 'promise rejected when imageinfo is missing' );
|
||||
done();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ThumbnailInfo missing page test', function ( assert ) {
|
||||
QUnit.test( 'ThumbnailInfo missing page test', ( assert ) => {
|
||||
const api = { get: function () {
|
||||
return $.Deferred().resolve( {
|
||||
query: {
|
||||
|
@ -190,14 +190,14 @@ const { ThumbnailInfo } = require( 'mmv' );
|
|||
const done = assert.async();
|
||||
const thumbnailInfoProvider = new ThumbnailInfo( api );
|
||||
|
||||
thumbnailInfoProvider.get( file ).fail( function ( errorMessage ) {
|
||||
thumbnailInfoProvider.get( file ).fail( ( errorMessage ) => {
|
||||
assert.strictEqual( errorMessage, 'file does not exist: File:Stuff.jpg',
|
||||
'error message is set correctly for missing file' );
|
||||
done();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'ThumbnailInfo fail test 3', function ( assert ) {
|
||||
QUnit.test( 'ThumbnailInfo fail test 3', ( assert ) => {
|
||||
const api = { get: function () {
|
||||
return $.Deferred().resolve( {
|
||||
query: {
|
||||
|
@ -216,7 +216,7 @@ const { ThumbnailInfo } = require( 'mmv' );
|
|||
const done = assert.async();
|
||||
const thumbnailInfoProvider = new ThumbnailInfo( api );
|
||||
|
||||
thumbnailInfoProvider.get( file, 100 ).fail( function () {
|
||||
thumbnailInfoProvider.get( file, 100 ).fail( () => {
|
||||
assert.true( true, 'promise rejected when thumbnail info is missing' );
|
||||
done();
|
||||
} );
|
||||
|
|
|
@ -21,7 +21,7 @@ const { Canvas } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.ui.Canvas', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'Constructor sense check', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const canvas = new Canvas( $qf, $qf, $qf );
|
||||
|
||||
|
@ -30,7 +30,7 @@ const { Canvas } = require( 'mmv' );
|
|||
assert.strictEqual( canvas.$mainWrapper, $qf, '$mainWrapper is set correctly.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'empty() and set()', function ( assert ) {
|
||||
QUnit.test( 'empty() and set()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const canvas = new Canvas( $qf );
|
||||
const image = new Image();
|
||||
|
@ -55,7 +55,7 @@ const { Canvas } = require( 'mmv' );
|
|||
assert.strictEqual( canvas.$imageDiv.hasClass( 'empty' ), true, 'Canvas is not visible.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'setImageAndMaxDimensions()', function ( assert ) {
|
||||
QUnit.test( 'setImageAndMaxDimensions()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const $mainWrapper = $( '<div>' ).appendTo( $qf );
|
||||
const $innerWrapper = $( '<div>' ).appendTo( $mainWrapper );
|
||||
|
@ -96,7 +96,7 @@ const { Canvas } = require( 'mmv' );
|
|||
assert.notStrictEqual( canvas.$image, $currentImage, 'Image element switched correctly.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'maybeDisplayPlaceholder: Constrained area for SVG files', function ( assert ) {
|
||||
QUnit.test( 'maybeDisplayPlaceholder: Constrained area for SVG files', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const imageRawMetadata = new LightboxImage( 'foo.svg' );
|
||||
const canvas = new Canvas( $qf );
|
||||
|
@ -124,7 +124,7 @@ const { Canvas } = require( 'mmv' );
|
|||
assert.strictEqual( $image.height(), 5, 'Placeholder height was not set to max' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'maybeDisplayPlaceholder: placeholder big enough to show, actual image bigger than the lightbox', function ( assert ) {
|
||||
QUnit.test( 'maybeDisplayPlaceholder: placeholder big enough to show, actual image bigger than the lightbox', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const imageRawMetadata = new LightboxImage( 'foo.png' );
|
||||
const canvas = new Canvas( $qf );
|
||||
|
@ -152,7 +152,7 @@ const { Canvas } = require( 'mmv' );
|
|||
assert.strictEqual( $image.height(), 150, 'Placeholder has the right height' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'maybeDisplayPlaceholder: big-enough placeholder to show, actual image smaller than the lightbox', function ( assert ) {
|
||||
QUnit.test( 'maybeDisplayPlaceholder: big-enough placeholder to show, actual image smaller than the lightbox', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const imageRawMetadata = new LightboxImage( 'foo.png' );
|
||||
const canvas = new Canvas( $qf );
|
||||
|
@ -180,7 +180,7 @@ const { Canvas } = require( 'mmv' );
|
|||
assert.strictEqual( $image.height(), 500, 'Placeholder has the right height' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'maybeDisplayPlaceholder: placeholder too small to be displayed, actual image bigger than the lightbox', function ( assert ) {
|
||||
QUnit.test( 'maybeDisplayPlaceholder: placeholder too small to be displayed, actual image bigger than the lightbox', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const imageRawMetadata = new LightboxImage( 'foo.png' );
|
||||
const canvas = new Canvas( $qf );
|
||||
|
|
|
@ -20,15 +20,15 @@ const { CanvasButtons } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.ui.CanvasButtons', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Prev/Next', function ( assert ) {
|
||||
QUnit.test( 'Prev/Next', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const buttons = new CanvasButtons( $qf, $( '<div>' ), $( '<div>' ) );
|
||||
|
||||
buttons.on( 'next', function () {
|
||||
buttons.on( 'next', () => {
|
||||
assert.true( true, 'Switched to next image' );
|
||||
} );
|
||||
|
||||
buttons.on( 'prev', function () {
|
||||
buttons.on( 'prev', () => {
|
||||
assert.true( true, 'Switched to prev image' );
|
||||
} );
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const { Description } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.ui.description', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Sense test, object creation and UI construction', function ( assert ) {
|
||||
QUnit.test( 'Sense test, object creation and UI construction', ( assert ) => {
|
||||
const description = new Description( $( '#qunit-fixture' ) );
|
||||
|
||||
assert.true( description instanceof Description, 'Image description UI element is created' );
|
||||
|
@ -11,7 +11,7 @@ const { Description } = require( 'mmv' );
|
|||
assert.strictEqual( description.$imageDesc.length, 1, 'Image description element is created' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Setting data in different combinations works well', function ( assert ) {
|
||||
QUnit.test( 'Setting data in different combinations works well', ( assert ) => {
|
||||
const description = new Description( $( '#qunit-fixture' ) );
|
||||
|
||||
description.set( null, null );
|
||||
|
@ -33,7 +33,7 @@ const { Description } = require( 'mmv' );
|
|||
'Image description text is set correctly, caption is ignored' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Emptying data works as expected', function ( assert ) {
|
||||
QUnit.test( 'Emptying data works as expected', ( assert ) => {
|
||||
const description = new Description( $( '#qunit-fixture' ) );
|
||||
|
||||
description.set( 'foo', 'bar' );
|
||||
|
|
|
@ -20,7 +20,7 @@ const { Download: DownloadPane, Utils } = require( 'mmv.ui.reuse' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.ui.download.pane', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Sense test, object creation and UI construction', function ( assert ) {
|
||||
QUnit.test( 'Sense test, object creation and UI construction', ( assert ) => {
|
||||
const download = new DownloadPane( $( '#qunit-fixture' ) );
|
||||
|
||||
assert.true( download instanceof DownloadPane, 'download UI element is created.' );
|
||||
|
@ -33,7 +33,7 @@ const { Download: DownloadPane, Utils } = require( 'mmv.ui.reuse' );
|
|||
assert.strictEqual( download.$previewLink.attr( 'href' ), undefined, 'Preview link href is empty.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'set()/empty():', function ( assert ) {
|
||||
QUnit.test( 'set()/empty():', ( assert ) => {
|
||||
const download = new DownloadPane( $( '#qunit-fixture' ) );
|
||||
const src = 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg';
|
||||
const image = { // fake ImageModel
|
||||
|
@ -60,7 +60,7 @@ const { Download: DownloadPane, Utils } = require( 'mmv.ui.reuse' );
|
|||
Utils.updateMenuOptions = updateMenuOptions;
|
||||
} );
|
||||
|
||||
QUnit.test( 'handleSizeSwitch():', function ( assert ) {
|
||||
QUnit.test( 'handleSizeSwitch():', ( assert ) => {
|
||||
const download = new DownloadPane( $( '#qunit-fixture' ) );
|
||||
const newImageUrl = 'https://upload.wikimedia.org/wikipedia/commons/3/3a/NewFoobar.jpg';
|
||||
|
||||
|
@ -86,14 +86,14 @@ const { Download: DownloadPane, Utils } = require( 'mmv.ui.reuse' );
|
|||
Utils.getThumbnailUrlPromise = getThumbnailUrlPromise;
|
||||
} );
|
||||
|
||||
QUnit.test( 'getExtensionFromUrl():', function ( assert ) {
|
||||
QUnit.test( 'getExtensionFromUrl():', ( assert ) => {
|
||||
const download = new DownloadPane( $( '#qunit-fixture' ) );
|
||||
|
||||
assert.strictEqual( download.getExtensionFromUrl( 'http://example.com/bing/foo.bar.png' ),
|
||||
'png', 'Extension is parsed correctly' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'setDownloadUrl', function ( assert ) {
|
||||
QUnit.test( 'setDownloadUrl', ( assert ) => {
|
||||
const download = new DownloadPane( $( '#qunit-fixture' ) );
|
||||
const imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/3/3a/NewFoobar.jpg';
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const { MetadataPanel, License } = require( 'mmv' );
|
|||
|
||||
QUnit.module( 'mmv.ui.metadataPanel', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( '.empty()', function ( assert ) {
|
||||
QUnit.test( '.empty()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const panel = new MetadataPanel(
|
||||
$qf,
|
||||
|
@ -19,7 +19,7 @@ QUnit.test( '.empty()', function ( assert ) {
|
|||
'$location',
|
||||
'$datetimeCreated',
|
||||
'$datetimeUpdated'
|
||||
].forEach( function ( thing ) {
|
||||
].forEach( ( thing ) => {
|
||||
assert.strictEqual( panel[ thing ].text(), '', thing + ' empty text' );
|
||||
} );
|
||||
|
||||
|
@ -29,12 +29,12 @@ QUnit.test( '.empty()', function ( assert ) {
|
|||
'$locationLi',
|
||||
'$datetimeCreatedLi',
|
||||
'$datetimeUpdatedLi'
|
||||
].forEach( function ( thing ) {
|
||||
].forEach( ( thing ) => {
|
||||
assert.true( panel[ thing ].hasClass( 'empty' ), thing + ' empty class' );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( '.setLocationData()', function ( assert ) {
|
||||
QUnit.test( '.setLocationData()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const panel = new MetadataPanel(
|
||||
$qf,
|
||||
|
@ -172,7 +172,7 @@ QUnit.test( '.setImageInfo()', function ( assert ) {
|
|||
} );
|
||||
|
||||
// FIXME: test broken since migrating to require/packageFiles
|
||||
QUnit.skip( 'Setting permission information works as expected', function ( assert ) {
|
||||
QUnit.skip( 'Setting permission information works as expected', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const panel = new MetadataPanel(
|
||||
$qf,
|
||||
|
@ -187,7 +187,7 @@ QUnit.skip( 'Setting permission information works as expected', function ( asser
|
|||
assert.true( panel.$permissionLink.is( ':visible' ) );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Date formatting', function ( assert ) {
|
||||
QUnit.test( 'Date formatting', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const panel = new MetadataPanel(
|
||||
$qf,
|
||||
|
|
|
@ -25,7 +25,7 @@ const { MetadataPanelScroller } = require( 'mmv' );
|
|||
}
|
||||
} ) );
|
||||
|
||||
QUnit.test( 'empty()', function ( assert ) {
|
||||
QUnit.test( 'empty()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const localStorage = getFakeLocalStorage();
|
||||
const scroller = new MetadataPanelScroller( $qf, $( '<div>' ).appendTo( $qf ), localStorage );
|
||||
|
@ -34,7 +34,7 @@ const { MetadataPanelScroller } = require( 'mmv' );
|
|||
assert.strictEqual( scroller.$container.hasClass( 'invite' ), false, 'We successfully reset the invite' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Metadata div is only animated once', function ( assert ) {
|
||||
QUnit.test( 'Metadata div is only animated once', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
let displayCount = null; // pretend it doesn't exist at first
|
||||
const localStorage = createLocalStorage( {
|
||||
|
|
|
@ -25,14 +25,14 @@ const { Permission } = require( 'mmv' );
|
|||
}
|
||||
} ) );
|
||||
|
||||
QUnit.test( 'Constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'Constructor sense check', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const permission = new Permission( $qf );
|
||||
|
||||
assert.true( permission instanceof Permission, 'constructor does not throw error' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'set()', function ( assert ) {
|
||||
QUnit.test( 'set()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const permission = new Permission( $qf );
|
||||
const text = 'Nothing to see here.';
|
||||
|
@ -48,7 +48,7 @@ const { Permission } = require( 'mmv' );
|
|||
assert.strictEqual( permission.$close.is( ':visible' ), false, 'close button is not visible' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'set() with html', function ( assert ) {
|
||||
QUnit.test( 'set() with html', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const permission = new Permission( $qf );
|
||||
const text = '<b>Nothing</b> to see here.';
|
||||
|
@ -59,7 +59,7 @@ const { Permission } = require( 'mmv' );
|
|||
assert.strictEqual( permission.$html.find( 'b' ).length, 1, 'permission html has html' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'empty()', function ( assert ) {
|
||||
QUnit.test( 'empty()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const permission = new Permission( $qf );
|
||||
const text = 'Nothing to see here.';
|
||||
|
@ -72,7 +72,7 @@ const { Permission } = require( 'mmv' );
|
|||
assert.strictEqual( permission.$close.is( ':visible' ), false, 'close button is not visible' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'grow()', function ( assert ) {
|
||||
QUnit.test( 'grow()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const permission = new Permission( $qf );
|
||||
const text = 'Nothing to see here.';
|
||||
|
@ -85,7 +85,7 @@ const { Permission } = require( 'mmv' );
|
|||
assert.strictEqual( permission.$close.is( ':visible' ), true, 'close button is visible' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'shrink()', function ( assert ) {
|
||||
QUnit.test( 'shrink()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const permission = new Permission( $qf );
|
||||
const text = 'Nothing to see here.';
|
||||
|
@ -99,7 +99,7 @@ const { Permission } = require( 'mmv' );
|
|||
assert.strictEqual( permission.$close.is( ':visible' ), false, 'close button is not visible' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'isFullSize()', function ( assert ) {
|
||||
QUnit.test( 'isFullSize()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const permission = new Permission( $qf );
|
||||
const text = 'Nothing to see here.';
|
||||
|
|
|
@ -20,13 +20,13 @@ const { ProgressBar } = require( 'mmv' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.ui.ProgressBar', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Constructor sense check', function ( assert ) {
|
||||
QUnit.test( 'Constructor sense check', ( assert ) => {
|
||||
const progressBar = new ProgressBar( $( '<div>' ) );
|
||||
assert.true( progressBar instanceof ProgressBar, 'ProgressBar created sccessfully' );
|
||||
assert.strictEqual( progressBar.$progress.hasClass( 'empty' ), true, 'ProgressBar starts empty' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'animateTo()', function ( assert ) {
|
||||
QUnit.test( 'animateTo()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const $div = $( '<div>' ).css( { width: 250, position: 'relative' } ).appendTo( $qf );
|
||||
const progress = new ProgressBar( $div );
|
||||
|
@ -48,7 +48,7 @@ const { ProgressBar } = require( 'mmv' );
|
|||
assert.strictEqual( progress.$percent.width(), 0, 'Progress bar\'s indicator is back to 0 and hidden' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'jumpTo()/hide()', function ( assert ) {
|
||||
QUnit.test( 'jumpTo()/hide()', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const $div = $( '<div>' ).css( { width: 250, position: 'relative' } ).appendTo( $qf );
|
||||
const progress = new ProgressBar( $div );
|
||||
|
|
|
@ -22,7 +22,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
|
||||
QUnit.module( 'mmv.ui.reuse.Embed', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Sense test, object creation and UI construction', function ( assert ) {
|
||||
QUnit.test( 'Sense test, object creation and UI construction', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
|
||||
assert.true( embed instanceof Embed, 'Embed UI element is created.' );
|
||||
|
@ -32,7 +32,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
assert.true( embed.$embedSizeSwitchHtml[ 0 ] instanceof HTMLElement, 'Size selection menu for html created.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'handleSizeSwitch(): Skip if no item selected.', function ( assert ) {
|
||||
QUnit.test( 'handleSizeSwitch(): Skip if no item selected.', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
|
||||
assert.expect( 0 );
|
||||
|
@ -50,7 +50,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
embed.handleSizeSwitch();
|
||||
} );
|
||||
|
||||
QUnit.test( 'handleSizeSwitch(): HTML/Wikitext size menu item selected.', function ( assert ) {
|
||||
QUnit.test( 'handleSizeSwitch(): HTML/Wikitext size menu item selected.', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const width = '10';
|
||||
const height = '20';
|
||||
|
@ -75,7 +75,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
embed.handleSizeSwitch();
|
||||
} );
|
||||
|
||||
QUnit.test( 'handleSizeSwitch(): Wikitext size menu item selected.', function ( assert ) {
|
||||
QUnit.test( 'handleSizeSwitch(): Wikitext size menu item selected.', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const width = '10';
|
||||
const height = '20';
|
||||
|
@ -98,7 +98,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
embed.handleSizeSwitch();
|
||||
} );
|
||||
|
||||
QUnit.test( 'updateEmbedHtml(): Do nothing if set() not called before.', function ( assert ) {
|
||||
QUnit.test( 'updateEmbedHtml(): Do nothing if set() not called before.', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const width = 10;
|
||||
const height = 20;
|
||||
|
@ -111,7 +111,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
embed.updateEmbedHtml( {}, width, height );
|
||||
} );
|
||||
|
||||
QUnit.test( 'updateEmbedHtml():', function ( assert ) {
|
||||
QUnit.test( 'updateEmbedHtml():', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const title = mw.Title.newFromText( 'File:Foobar.jpg' );
|
||||
const url = 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg';
|
||||
|
@ -154,7 +154,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
embed.updateEmbedHtml( { url: thumbUrl }, width, height );
|
||||
} );
|
||||
|
||||
QUnit.test( 'updateEmbedWikitext(): Do nothing if set() not called before.', function ( assert ) {
|
||||
QUnit.test( 'updateEmbedWikitext(): Do nothing if set() not called before.', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const width = 10;
|
||||
|
||||
|
@ -166,7 +166,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
embed.updateEmbedWikitext( width );
|
||||
} );
|
||||
|
||||
QUnit.test( 'updateEmbedWikitext():', function ( assert ) {
|
||||
QUnit.test( 'updateEmbedWikitext():', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const title = mw.Title.newFromText( 'File:Foobar.jpg' );
|
||||
const url = 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg';
|
||||
|
@ -192,7 +192,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
embed.updateEmbedWikitext( width );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getPossibleImageSizesForWikitext()', function ( assert ) {
|
||||
QUnit.test( 'getPossibleImageSizesForWikitext()', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const exampleSizes = [
|
||||
// Big wide image
|
||||
|
@ -229,7 +229,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
}
|
||||
} );
|
||||
|
||||
QUnit.test( 'set():', function ( assert ) {
|
||||
QUnit.test( 'set():', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const width = 15;
|
||||
const height = 20;
|
||||
|
@ -259,7 +259,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
Utils.getThumbnailUrlPromise = getThumbnailUrlPromise;
|
||||
} );
|
||||
|
||||
QUnit.test( 'empty():', function ( assert ) {
|
||||
QUnit.test( 'empty():', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const width = 15;
|
||||
const height = 20;
|
||||
|
@ -288,7 +288,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
assert.strictEqual( embed.$embedSizeSwitchWikitext.css( 'display' ), 'none', 'Wikitext size menu should be hidden.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'attach()/unattach():', function ( assert ) {
|
||||
QUnit.test( 'attach()/unattach():', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
const width = 15;
|
||||
const height = 20;
|
||||
|
@ -336,7 +336,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
embed.$embedSizeSwitchWikitext.trigger( 'change' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'handleTypeSwitch():', function ( assert ) {
|
||||
QUnit.test( 'handleTypeSwitch():', ( assert ) => {
|
||||
const embed = new Embed( $qf );
|
||||
|
||||
embed.resetCurrentSizeMenuToDefault = function () {
|
||||
|
@ -358,7 +358,7 @@ const { Embed, Utils } = require( 'mmv.ui.reuse' );
|
|||
assert.strictEqual( embed.$embedSizeSwitchHtml.css( 'display' ), 'none', 'HTML size menu should be hidden.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Logged out', function ( assert ) {
|
||||
QUnit.test( 'Logged out', ( assert ) => {
|
||||
const oldUserIsAnon = mw.user.isAnon;
|
||||
|
||||
mw.user.isAnon = () => true;
|
||||
|
|
|
@ -24,14 +24,14 @@ const { Share } = require( 'mmv.ui.reuse' );
|
|||
|
||||
QUnit.module( 'mmv.ui.reuse.share', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Sense test, object creation and UI construction', function ( assert ) {
|
||||
QUnit.test( 'Sense test, object creation and UI construction', ( assert ) => {
|
||||
const share = makeShare();
|
||||
|
||||
assert.true( share instanceof Share, 'Share UI element is created.' );
|
||||
assert.true( share.$pageInput[ 0 ] instanceof HTMLElement, 'Text field created.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'set()/empty():', function ( assert ) {
|
||||
QUnit.test( 'set()/empty():', ( assert ) => {
|
||||
const share = makeShare();
|
||||
const image = { // fake ImageModel
|
||||
title: new mw.Title( 'File:Foobar.jpg' ),
|
||||
|
|
|
@ -20,7 +20,7 @@ const { Utils } = require( 'mmv.ui.reuse' );
|
|||
( function () {
|
||||
QUnit.module( 'mmv.ui.reuse.utils', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'createSelectMenu():', function ( assert ) {
|
||||
QUnit.test( 'createSelectMenu():', ( assert ) => {
|
||||
const menuItems = [ 'original', 'small', 'medium', 'large' ];
|
||||
const def = 'large';
|
||||
const $select = Utils.createSelectMenu(
|
||||
|
@ -40,7 +40,7 @@ const { Utils } = require( 'mmv.ui.reuse' );
|
|||
}
|
||||
} );
|
||||
|
||||
QUnit.test( 'updateSelectOptions():', function ( assert ) {
|
||||
QUnit.test( 'updateSelectOptions():', ( assert ) => {
|
||||
const $select = Utils.createSelectMenu(
|
||||
[ 'original', 'small', 'medium', 'large' ],
|
||||
'original'
|
||||
|
@ -62,7 +62,7 @@ const { Utils } = require( 'mmv.ui.reuse' );
|
|||
mw.message = oldMessage;
|
||||
} );
|
||||
|
||||
QUnit.test( 'getPossibleImageSizesForHtml()', function ( assert ) {
|
||||
QUnit.test( 'getPossibleImageSizesForHtml()', ( assert ) => {
|
||||
const exampleSizes = [
|
||||
{
|
||||
test: 'Extra large wide image',
|
||||
|
|
|
@ -25,7 +25,7 @@ const { StripeButtons } = require( 'mmv' );
|
|||
return new StripeButtons( $fixture );
|
||||
}
|
||||
|
||||
QUnit.test( 'Sense test, object creation and UI construction', function ( assert ) {
|
||||
QUnit.test( 'Sense test, object creation and UI construction', ( assert ) => {
|
||||
const oldMwUserIsAnon = mw.user.isAnon;
|
||||
|
||||
// first pretend we are anonymous
|
||||
|
@ -44,7 +44,7 @@ const { StripeButtons } = require( 'mmv' );
|
|||
mw.user.isAnon = oldMwUserIsAnon;
|
||||
} );
|
||||
|
||||
QUnit.test( 'set()/empty() sense test:', function ( assert ) {
|
||||
QUnit.test( 'set()/empty() sense test:', ( assert ) => {
|
||||
const buttons = createStripeButtons();
|
||||
const fakeImageInfo = { descriptionUrl: '//commons.wikimedia.org/wiki/File:Foo.jpg' };
|
||||
|
||||
|
@ -54,7 +54,7 @@ const { StripeButtons } = require( 'mmv' );
|
|||
assert.true( true, 'No error on set()/empty().' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Description page button', function ( assert ) {
|
||||
QUnit.test( 'Description page button', ( assert ) => {
|
||||
const $qf = $( '#qunit-fixture' );
|
||||
const buttons = new StripeButtons( $qf );
|
||||
const $button = buttons.$descriptionPage;
|
||||
|
|
|
@ -7,10 +7,10 @@ const { UiElement } = require( 'mmv' );
|
|||
}
|
||||
} ) );
|
||||
|
||||
QUnit.test( 'handleEvent()', function ( assert ) {
|
||||
QUnit.test( 'handleEvent()', ( assert ) => {
|
||||
const element = new UiElement( $( '<div>' ) );
|
||||
|
||||
element.handleEvent( 'mmv-foo', function () {
|
||||
element.handleEvent( 'mmv-foo', () => {
|
||||
assert.true( true, 'Event is handled' );
|
||||
} );
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ const { TruncatableTextField } = require( 'mmv' );
|
|||
return ttf;
|
||||
}
|
||||
|
||||
QUnit.test( 'Normal constructor', function ( assert ) {
|
||||
QUnit.test( 'Normal constructor', ( assert ) => {
|
||||
const $container = $( '#qunit-fixture' );
|
||||
const $element = $( '<div>' ).appendTo( $container ).text( 'This is a unique string.' );
|
||||
const ttf = new TruncatableTextField( $container, $element );
|
||||
|
|
|
@ -15,12 +15,12 @@ const { OptionsDialog } = require( 'mmv' );
|
|||
|
||||
QUnit.module( 'mmv.ui.viewingOptions', QUnit.newMwEnvironment() );
|
||||
|
||||
QUnit.test( 'Constructor sense test', function ( assert ) {
|
||||
QUnit.test( 'Constructor sense test', ( assert ) => {
|
||||
const dialog = makeDialog();
|
||||
assert.true( dialog instanceof OptionsDialog, 'Dialog is created successfully' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'Initialisation functions', function ( assert ) {
|
||||
QUnit.test( 'Initialisation functions', ( assert ) => {
|
||||
const dialog = makeDialog( true );
|
||||
|
||||
assert.strictEqual( dialog.$disableDiv.length, 1, 'Disable div is created.' );
|
||||
|
@ -33,9 +33,7 @@ const { OptionsDialog } = require( 'mmv' );
|
|||
const dialog = makeDialog();
|
||||
const deferred = $.Deferred();
|
||||
|
||||
this.sandbox.stub( dialog.config, 'setMediaViewerEnabledOnClick', function () {
|
||||
return deferred;
|
||||
} );
|
||||
this.sandbox.stub( dialog.config, 'setMediaViewerEnabledOnClick', () => deferred );
|
||||
|
||||
dialog.initDisableDiv();
|
||||
|
||||
|
@ -84,9 +82,7 @@ const { OptionsDialog } = require( 'mmv' );
|
|||
const dialog = makeDialog();
|
||||
const deferred = $.Deferred();
|
||||
|
||||
this.sandbox.stub( dialog.config, 'setMediaViewerEnabledOnClick', function () {
|
||||
return deferred;
|
||||
} );
|
||||
this.sandbox.stub( dialog.config, 'setMediaViewerEnabledOnClick', () => deferred );
|
||||
|
||||
dialog.initEnableDiv();
|
||||
|
||||
|
|
Loading…
Reference in a new issue