2016-12-14 13:48:20 +00:00
|
|
|
( function ( mw ) {
|
|
|
|
|
|
|
|
function createStubUserSettings( hasIsEnabled ) {
|
|
|
|
return {
|
|
|
|
hasIsEnabled: function () {
|
|
|
|
return hasIsEnabled;
|
|
|
|
},
|
|
|
|
getIsEnabled: function () {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
QUnit.module( 'ext.popups#isEnabled' );
|
|
|
|
|
|
|
|
QUnit.test( 'it should return true when the user has enabled it via UI interactions', function ( assert ) {
|
|
|
|
var user = mw.popups.tests.stubs.createStubUser( /* isAnon = */ false ),
|
2016-12-14 14:24:21 +00:00
|
|
|
userSettings = createStubUserSettings( /* hasIsEnabled = */ true );
|
2016-12-14 13:48:20 +00:00
|
|
|
|
2016-12-14 14:24:21 +00:00
|
|
|
assert.ok( mw.popups.isEnabled( user, userSettings ) );
|
2016-12-14 13:48:20 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'it should return false if the user is an anon', function ( assert ) {
|
|
|
|
var user = mw.popups.tests.stubs.createStubUser( /* isAnon = */ true ),
|
2016-12-14 14:24:21 +00:00
|
|
|
userSettings = createStubUserSettings( /* hasIsEnabled = */ true );
|
2016-12-14 13:48:20 +00:00
|
|
|
|
|
|
|
assert.notOk(
|
2016-12-14 14:24:21 +00:00
|
|
|
mw.popups.isEnabled( user, userSettings ),
|
2016-12-14 13:48:20 +00:00
|
|
|
'It should return false even if the user has enabled it via UI interactions.'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'it should return true if the user hasn\'t disabled it via UI interactions', function ( assert ) {
|
|
|
|
var user = mw.popups.tests.stubs.createStubUser( /* isAnon = */ false ),
|
2016-12-14 14:24:21 +00:00
|
|
|
userSettings = createStubUserSettings( /* hasIsEnabled = */ false );
|
2016-12-14 13:48:20 +00:00
|
|
|
|
2016-12-14 14:24:21 +00:00
|
|
|
assert.ok( mw.popups.isEnabled( user, userSettings ) );
|
2016-12-14 13:48:20 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
}( mediaWiki ) );
|