From 3d350a29abb85328404e27846673dfa86f30693b Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Thu, 10 Oct 2024 12:40:33 +0200 Subject: [PATCH] Fix mmv.ui.metadataPanel.test.js Regression of I3a4024ccf90e50558152d4ee012e492f49e14a0e: unless mw.messages.exists the license shortName CC-BY-2.0 is returned, breaking "License is correctly set" in setImageInfo() in mmv.ui.metadataPanel.test. Change-Id: I35f67fa3d160d771970b5695fb93f5de7ea2d41d --- .../qunit/mmv/ui/mmv.ui.metadataPanel.test.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js b/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js index 915321e52..0edcecc19 100644 --- a/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js +++ b/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js @@ -1,7 +1,16 @@ const { Config } = require( 'mmv.bootstrap' ); const { MetadataPanel, License } = require( 'mmv' ); -QUnit.module( 'mmv.ui.metadataPanel', QUnit.newMwEnvironment() ); +const mwMessagesExists = mw.messages.exists; +QUnit.module( 'mmv.ui.metadataPanel', QUnit.newMwEnvironment( { + beforeEach: () => { + // mock mw.messages.exists for License.getShortLink (multimediaviewer-license-cc-by-2.0) + mw.messages.exists = () => true; + }, + afterEach: () => { + mw.messages.exists = mwMessagesExists; + } +} ) ); QUnit.test( '.empty()', ( assert ) => { const $qf = $( '#qunit-fixture' ); @@ -46,9 +55,7 @@ QUnit.test( '.setLocationData()', ( assert ) => { const imageData = { latitude: latitude, longitude: longitude, - hasCoords: function () { - return true; - }, + hasCoords: () => true, title: mw.Title.newFromText( 'File:Foobar.jpg' ) }; @@ -116,9 +123,7 @@ QUnit.test( '.setImageInfo()', function ( assert ) { title: image.filePageTitle, url: 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg', descriptionUrl: 'https://commons.wikimedia.org/wiki/File:Foobar.jpg', - hasCoords: function () { - return false; - } + hasCoords: () => false }; const clock = this.sandbox.useFakeTimers();