behave like cacheFactory, add put method

master
Chakib Benziane 9 years ago
parent a07d51c3e7
commit 15ad8a603e

@ -406,6 +406,7 @@ angularLocalStorage.provider('localStorageService', function() {
isSupported: browserSupportsLocalStorage, isSupported: browserSupportsLocalStorage,
getStorageType: getStorageType, getStorageType: getStorageType,
set: addToLocalStorage, set: addToLocalStorage,
put: addToLocalStorage,
add: addToLocalStorage, //DEPRECATED add: addToLocalStorage, //DEPRECATED
get: getFromLocalStorage, get: getFromLocalStorage,
keys: getKeysForLocalStorage, keys: getKeysForLocalStorage,

@ -18,6 +18,14 @@ describe('localStorageService', function() {
}; };
} }
function addItem(key, value) {
return function($window, localStorageService) {
elmSpy = spyOn($window.localStorage, 'setItem').andCallThrough();
localStorageService.put(key, value);
};
}
function removeItem(key) { function removeItem(key) {
return function($window, localStorageService) { return function($window, localStorageService) {
elmSpy = spyOn($window.localStorage, 'removeItem').andCallThrough(); elmSpy = spyOn($window.localStorage, 'removeItem').andCallThrough();