mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-27 09:30:02 +00:00
Don't use mw.Map(), use a native Map() instead
Bug: T353076 Change-Id: I91a556becc1093e0db4c4b13e4685f2c0e084031
This commit is contained in:
parent
ef53ab0834
commit
07ba0e43a9
|
@ -30,8 +30,8 @@
|
|||
"jQuery.Deferred": "https://api.jquery.com/category/deferred-object/",
|
||||
"jQuery.Event": "https://api.jquery.com/category/events/event-object/",
|
||||
"jQuery.Promise": "https://api.jquery.com/Types/#Promise",
|
||||
"Map": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map",
|
||||
"mw.Api": "https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Api",
|
||||
"mw.Map": "https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Map",
|
||||
"mw.SafeStorage": "https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.SafeStorage",
|
||||
"mw.Title": "https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title",
|
||||
"mw.widgets.CopyTextLayout": "https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.widgets.CopyTextLayout",
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class Config {
|
||||
/**
|
||||
* @param {Object} viewerConfig
|
||||
* @param {mw.Map} mwConfig
|
||||
* @param {Map} mwConfig
|
||||
* @param {Object} mwUser
|
||||
* @param {mw.Api} api
|
||||
* @param {mw.SafeStorage} localStorage
|
||||
|
@ -39,7 +39,7 @@
|
|||
/**
|
||||
* The mw.config object, for dependency injection
|
||||
*
|
||||
* @type {mw.Map}
|
||||
* @type {Map}
|
||||
*/
|
||||
this.mwConfig = mwConfig;
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ const { createLocalStorage, getDisabledLocalStorage, getFakeLocalStorage, getUns
|
|||
removeItem: this.sandbox.stub()
|
||||
} );
|
||||
const mwUser = { isNamed: this.sandbox.stub() };
|
||||
const mwConfig = new mw.Map();
|
||||
const mwConfig = new Map();
|
||||
const api = { saveOption: this.sandbox.stub().returns( $.Deferred().resolve() ) };
|
||||
const config = new Config( {}, mwConfig, mwUser, api, localStorage );
|
||||
mwConfig.set( 'wgMediaViewerEnabledByDefault', false );
|
||||
|
@ -159,16 +159,14 @@ const { createLocalStorage, getDisabledLocalStorage, getFakeLocalStorage, getUns
|
|||
} );
|
||||
|
||||
QUnit.test( 'shouldShowStatusInfo', function ( assert ) {
|
||||
const mwConfig = new mw.Map();
|
||||
const mwConfig = new Map();
|
||||
const fakeLocalStorage = getFakeLocalStorage();
|
||||
const mwUser = { isNamed: this.sandbox.stub() };
|
||||
const api = { saveOption: this.sandbox.stub().returns( $.Deferred().resolve() ) };
|
||||
|
||||
mwConfig.set( {
|
||||
wgMediaViewer: true,
|
||||
wgMediaViewerOnClick: true,
|
||||
wgMediaViewerEnabledByDefault: true
|
||||
} );
|
||||
mwConfig.set( 'wgMediaViewer', true );
|
||||
mwConfig.set( 'wgMediaViewerOnClick', true );
|
||||
mwConfig.set( 'wgMediaViewerEnabledByDefault', true );
|
||||
const config = new Config( {}, mwConfig, mwUser, api, fakeLocalStorage );
|
||||
mwUser.isNamed.returns( true );
|
||||
|
||||
|
|
|
@ -58,17 +58,14 @@ const { MultimediaViewer } = require( 'mmv' );
|
|||
/**
|
||||
* Returns a fake local storage which is not saved between reloads.
|
||||
*
|
||||
* @param {Object} [initialData]
|
||||
* @return {mw.SafeStorage} Local storage-like object
|
||||
*/
|
||||
MTH.getFakeLocalStorage = function ( initialData ) {
|
||||
const bag = new mw.Map();
|
||||
bag.set( initialData );
|
||||
|
||||
MTH.getFakeLocalStorage = function () {
|
||||
const bag = new Map();
|
||||
return MTH.createLocalStorage( {
|
||||
getItem: function ( key ) { return bag.get( key ); },
|
||||
setItem: function ( key, value ) { bag.set( key, value ); },
|
||||
removeItem: function ( key ) { bag.set( key, null ); }
|
||||
getItem: ( key ) => bag.get( key ) || null,
|
||||
setItem: ( key, value ) => bag.set( key, value ),
|
||||
removeItem: ( key ) => bag.delete( key )
|
||||
} );
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue