|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
describe('Tests functionality of the localStorage module', function(){
|
|
|
|
|
beforeEach(module('LocalStorageModule'));
|
|
|
|
|
var ls, store = {};
|
|
|
|
|
var ls, store = [];
|
|
|
|
|
beforeEach(inject(function(_localStorageService_){
|
|
|
|
|
ls = _localStorageService_;
|
|
|
|
|
|
|
|
|
@ -10,12 +10,16 @@ describe('Tests functionality of the localStorage module', function(){
|
|
|
|
|
}else{
|
|
|
|
|
return store[key];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
spyOn(ls, 'set').andCallFake(function(key, val){
|
|
|
|
|
if(typeof val === "object"){
|
|
|
|
|
if(angular.isObject(val) || angular.isArray(val)){
|
|
|
|
|
val = angular.toJson(val);
|
|
|
|
|
}
|
|
|
|
|
if(angular.isNumber(val)){
|
|
|
|
|
val = val.toString();
|
|
|
|
|
}
|
|
|
|
|
return store[key] = val;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -26,8 +30,9 @@ describe('Tests functionality of the localStorage module', function(){
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
it("Should add a value to my local storage", function(){
|
|
|
|
|
ls.set('test', 'MyTest Value');
|
|
|
|
|
expect(ls.get('test')).toBe('MyTest Value');
|
|
|
|
|
var n = 234;
|
|
|
|
|
ls.set('test', n);
|
|
|
|
|
expect(ls.get('test')).toBe('234');
|
|
|
|
|
|
|
|
|
|
var obj = { key: 'val' };
|
|
|
|
|
ls.set('object', obj);
|
|
|
|
|