2017-08-09 09:14:52 +00:00
|
|
|
import createMwPopups from '../../../src/integrations/mwpopups';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @param {*} state
|
|
|
|
* @return {Object}
|
|
|
|
*/
|
|
|
|
function mockStore( state ) {
|
|
|
|
return {
|
2018-03-14 22:04:59 +00:00
|
|
|
getState() {
|
2017-08-09 09:14:52 +00:00
|
|
|
return state;
|
|
|
|
}
|
2017-08-02 19:03:24 +00:00
|
|
|
};
|
2017-08-09 09:14:52 +00:00
|
|
|
}
|
2017-08-02 19:03:24 +00:00
|
|
|
|
2017-08-09 09:14:52 +00:00
|
|
|
QUnit.module( 'ext.popups/integrations' );
|
2017-08-02 19:03:24 +00:00
|
|
|
|
|
|
|
QUnit.test( '#isEnabled returns correct value when disabled', function ( assert ) {
|
2018-03-19 19:39:41 +00:00
|
|
|
const state = {
|
2017-08-09 09:14:52 +00:00
|
|
|
preview: {
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
store = mockStore( state ),
|
|
|
|
popups = createMwPopups( store );
|
2017-08-02 19:03:24 +00:00
|
|
|
|
|
|
|
this.sandbox.spy( store, 'getState' );
|
|
|
|
|
2017-08-09 09:14:52 +00:00
|
|
|
assert.equal( popups.isEnabled(), false );
|
2017-08-02 19:03:24 +00:00
|
|
|
assert.ok( store.getState.calledOnce );
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( '#isEnabled returns correct value when enabled', function ( assert ) {
|
2018-03-19 19:39:41 +00:00
|
|
|
const state = {
|
2017-08-09 09:14:52 +00:00
|
|
|
preview: {
|
|
|
|
enabled: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
store = mockStore( state ),
|
|
|
|
popups = createMwPopups( store );
|
2017-08-02 19:03:24 +00:00
|
|
|
|
|
|
|
this.sandbox.spy( store, 'getState' );
|
|
|
|
|
2017-08-09 09:14:52 +00:00
|
|
|
assert.equal( popups.isEnabled(), true );
|
2017-08-02 19:03:24 +00:00
|
|
|
assert.ok( store.getState.calledOnce );
|
|
|
|
} );
|