mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-03 19:56:39 +00:00
622fb6c5e8
Bug: T277639 Change-Id: I0742b8ab1c5ed0b374d4f9447bebc46a35207339
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
import createMwPopups from '../../../src/integrations/mwpopups';
|
|
|
|
/**
|
|
* @private
|
|
* @param {*} state
|
|
* @return {Object}
|
|
*/
|
|
function mockStore( state ) {
|
|
return {
|
|
getState() {
|
|
return state;
|
|
}
|
|
};
|
|
}
|
|
|
|
QUnit.module( 'ext.popups/integrations' );
|
|
|
|
QUnit.test( '#isEnabled returns correct value when disabled', function ( assert ) {
|
|
const state = {
|
|
preview: {
|
|
enabled: { page: false }
|
|
}
|
|
},
|
|
store = mockStore( state ),
|
|
popups = createMwPopups( store );
|
|
|
|
this.sandbox.spy( store, 'getState' );
|
|
|
|
assert.strictEqual( popups.isEnabled(), false, 'Popups are disabled.' );
|
|
assert.strictEqual( store.getState.callCount, 1, 'The store was checked.' );
|
|
} );
|
|
|
|
QUnit.test( '#isEnabled returns correct value when enabled', function ( assert ) {
|
|
const state = {
|
|
preview: {
|
|
enabled: { page: true }
|
|
}
|
|
},
|
|
store = mockStore( state ),
|
|
popups = createMwPopups( store );
|
|
|
|
this.sandbox.spy( store, 'getState' );
|
|
|
|
assert.strictEqual( popups.isEnabled(), true, 'Popups are enabled.' );
|
|
assert.strictEqual( store.getState.callCount, 1, 'The store was checked.' );
|
|
} );
|