diff --git a/resources/dist/index.js b/resources/dist/index.js index b3f1e27de..b4df3d246 100644 Binary files a/resources/dist/index.js and b/resources/dist/index.js differ diff --git a/resources/dist/index.js.map b/resources/dist/index.js.map index e3003a3ea..c36b759b0 100644 Binary files a/resources/dist/index.js.map and b/resources/dist/index.js.map differ diff --git a/src/userSettings.js b/src/userSettings.js index 18166b6a4..d827a91f9 100644 --- a/src/userSettings.js +++ b/src/userSettings.js @@ -45,7 +45,9 @@ module.exports = function ( storage ) { * @return {Boolean} */ hasIsEnabled: function () { - return storage.get( IS_ENABLED_KEY, undefined ) !== undefined; + var value = storage.get( IS_ENABLED_KEY ); + + return Boolean( value ) !== false; }, /** diff --git a/tests/qunit/ext.popups/userSettings.test.js b/tests/qunit/ext.popups/userSettings.test.js index 63c23f743..66b46a660 100644 --- a/tests/qunit/ext.popups/userSettings.test.js +++ b/tests/qunit/ext.popups/userSettings.test.js @@ -9,11 +9,7 @@ } } ); - QUnit.test( '#getIsEnabled should return true if the storage is empty', 1, function ( assert ) { - assert.ok( this.userSettings.getIsEnabled() ); - } ); - - QUnit.test( '#getIsEnabled should return false if Link Previews have been disabled', 2, function ( assert ) { + QUnit.test( '#getIsEnabled should return false if Page Previews have been disabled', 2, function ( assert ) { this.userSettings.setIsEnabled( false ); assert.notOk( this.userSettings.getIsEnabled() ); @@ -28,8 +24,13 @@ ); } ); - QUnit.test( '#hasIsEnabled', 2, function ( assert ) { - assert.notOk( this.userSettings.hasIsEnabled() ); + QUnit.test( '#hasIsEnabled', 3, function ( assert ) { + var getStub; + + assert.notOk( + this.userSettings.hasIsEnabled(), + '#hasIsEnabled should return false if the storage is empty.' + ); // --- @@ -39,6 +40,17 @@ this.userSettings.hasIsEnabled(), '#hasIsEnabled should return true even if "isEnabled" has been set to falsy.' ); + + // --- + + getStub = this.sandbox.stub( this.storage, 'get' ).returns( false ); + + assert.notOk( + this.userSettings.hasIsEnabled(), + '#hasIsEnabled should return false if the storage is disabled.' + ); + + getStub.restore(); } ); QUnit.test( '#getPreviewCount should return the count as a number', function ( assert ) {