mirror of
https://github.com/nextcloud/passman.git
synced 2025-02-26 08:24:00 +08:00
No need to mock localstorage
This commit is contained in:
parent
a288f92eed
commit
d9dc7f8704
3 changed files with 2 additions and 53 deletions
|
@ -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'));
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue