2017-08-09 09:14:52 +00:00
|
|
|
import createMwPopups from '../../../src/integrations/mwpopups';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @param {*} state
|
|
|
|
* @return {Object}
|
|
|
|
*/
|
|
|
|
function mockStore( state ) {
|
|
|
|
return {
|
|
|
|
getState: function () {
|
|
|
|
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 ) {
|
2017-08-09 09:14:52 +00:00
|
|
|
var state = {
|
|
|
|
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 ) {
|
2017-08-09 09:14:52 +00:00
|
|
|
var state = {
|
|
|
|
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 );
|
|
|
|
} );
|