mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-17 20:41:32 +00:00
f37b76f8b4
Instead of registering global variables in a function, make it pure return the external interface and set it to mw.popups in the src/index.js entry point. Explicitly comment on index.js what is being set and why. Bug: T171287 Change-Id: I94d467bfa7fa6e56033dd254518ad50b5dde5bfc
47 lines
942 B
JavaScript
47 lines
942 B
JavaScript
import createMwPopups from '../../../src/integrations/mwpopups';
|
|
|
|
/**
|
|
* @private
|
|
* @param {*} state
|
|
* @return {Object}
|
|
*/
|
|
function mockStore( state ) {
|
|
return {
|
|
getState: function () {
|
|
return state;
|
|
}
|
|
};
|
|
}
|
|
|
|
QUnit.module( 'ext.popups/integrations' );
|
|
|
|
QUnit.test( '#isEnabled returns correct value when disabled', function ( assert ) {
|
|
var state = {
|
|
preview: {
|
|
enabled: false
|
|
}
|
|
},
|
|
store = mockStore( state ),
|
|
popups = createMwPopups( store );
|
|
|
|
this.sandbox.spy( store, 'getState' );
|
|
|
|
assert.equal( popups.isEnabled(), false );
|
|
assert.ok( store.getState.calledOnce );
|
|
} );
|
|
|
|
QUnit.test( '#isEnabled returns correct value when enabled', function ( assert ) {
|
|
var state = {
|
|
preview: {
|
|
enabled: true
|
|
}
|
|
},
|
|
store = mockStore( state ),
|
|
popups = createMwPopups( store );
|
|
|
|
this.sandbox.spy( store, 'getState' );
|
|
|
|
assert.equal( popups.isEnabled(), true );
|
|
assert.ok( store.getState.calledOnce );
|
|
} );
|