mediawiki-extensions-Popups/tests/node-qunit/integrations/mwpopups.test.js
Stephen Niedzielski a67466acc0 Hygiene: replace obvious function methods
Replace easily identifiable object functions with method syntax:

  find \
    -not \( \( -name node_modules -o -name .git -o -name vendor -o -name doc -o -name resources \) -prune \) \
    -iname \*.js|
  xargs -rd\\n sed -ri 's%:\s*function\s*(\([^)]*\))%\1%g'

Bug: T165036
Change-Id: I90693ee99a6a36dff820dd5ae6f6000429763058
2018-03-20 09:27:07 -05:00

47 lines
931 B
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 ) {
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 );
} );