From d9dc7f870495f9deeab2d94919c184da2bb3d6c3 Mon Sep 17 00:00:00 2001 From: brantje Date: Mon, 17 Oct 2016 19:40:17 +0200 Subject: [PATCH] No need to mock localstorage --- .../unit/js/app/controllers/credentialTest.js | 6 +-- tests/unit/js/app/controllers/menuTest.js | 7 +--- tests/unit/js/mocks/localStorageMock.js | 42 ------------------- 3 files changed, 2 insertions(+), 53 deletions(-) delete mode 100644 tests/unit/js/mocks/localStorageMock.js diff --git a/tests/unit/js/app/controllers/credentialTest.js b/tests/unit/js/app/controllers/credentialTest.js index 04e71a6b..c0a58da4 100644 --- a/tests/unit/js/app/controllers/credentialTest.js +++ b/tests/unit/js/app/controllers/credentialTest.js @@ -1,10 +1,6 @@ describe('CredentialCtrl', function() { var ctrl, scope, rootScope; - beforeEach(module('passmanApp', function ($provide) { - $provide.value('$window', { - localStorage: localStorageMock() - }); - })); + beforeEach(module('passmanApp')); beforeEach(module('LocalStorageModule')); beforeEach(module('mock.credentialsService')); diff --git a/tests/unit/js/app/controllers/menuTest.js b/tests/unit/js/app/controllers/menuTest.js index 27692e2a..bd2c1620 100644 --- a/tests/unit/js/app/controllers/menuTest.js +++ b/tests/unit/js/app/controllers/menuTest.js @@ -1,10 +1,5 @@ describe('MenuCtrl', function() { - beforeEach(module('passmanApp', function ($provide) { - $provide.value('$window', { - localStorage: localStorageMock() - }); - })); - + beforeEach(module('passmanApp')); beforeEach(module('LocalStorageModule')); var $controller; diff --git a/tests/unit/js/mocks/localStorageMock.js b/tests/unit/js/mocks/localStorageMock.js deleted file mode 100644 index ea449f33..00000000 --- a/tests/unit/js/mocks/localStorageMock.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; -//Mock localStorage -function localStorageMock() { - var storage = {}; - Object.defineProperties(storage, { - setItem: { - value: function(key, value) { - storage[key] = value || ''; - }, - enumerable: false, - writable: true - }, - getItem: { - value: function(key) { - return storage[key] ? storage[key] : null; - }, - enumerable: false, - writable: true - }, - removeItem: { - value: function(key) { - delete storage[key]; - }, - enumerable: false, - writable: true - }, - length: { - get: function() { - return Object.keys(storage).length; - }, - enumerable: false - }, - key: { - value: function(i) { - var aKeys = Object.keys(storage); - return aKeys[i] || null; - }, - enumerable: false - } - }); - return storage; -} \ No newline at end of file