mediawiki-extensions-Popups/tests/node-qunit/integrations/mwpopups.test.js

47 lines
942 B
JavaScript
Raw Normal View History

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 );
} );