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: {
|
2021-04-07 10:23:05 +00:00
|
|
|
enabled: { page: false }
|
2017-08-09 09:14:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
store = mockStore( state ),
|
|
|
|
popups = createMwPopups( store );
|
2017-08-02 19:03:24 +00:00
|
|
|
|
|
|
|
this.sandbox.spy( store, 'getState' );
|
|
|
|
|
2018-05-20 12:32:51 +00:00
|
|
|
assert.strictEqual( popups.isEnabled(), false, 'Popups are disabled.' );
|
2018-05-08 19:48:17 +00:00
|
|
|
assert.strictEqual( store.getState.callCount, 1, 'The store was checked.' );
|
2017-08-02 19:03:24 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
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: {
|
2021-04-07 10:23:05 +00:00
|
|
|
enabled: { page: true }
|
2017-08-09 09:14:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
store = mockStore( state ),
|
|
|
|
popups = createMwPopups( store );
|
2017-08-02 19:03:24 +00:00
|
|
|
|
|
|
|
this.sandbox.spy( store, 'getState' );
|
|
|
|
|
2018-05-20 12:32:51 +00:00
|
|
|
assert.strictEqual( popups.isEnabled(), true, 'Popups are enabled.' );
|
2018-05-08 19:48:17 +00:00
|
|
|
assert.strictEqual( store.getState.callCount, 1, 'The store was checked.' );
|
2017-08-02 19:03:24 +00:00
|
|
|
} );
|