From 650e9b825d14da14103f96b61e6e52062c851999 Mon Sep 17 00:00:00 2001 From: mwq27 Date: Sat, 2 Nov 2013 10:05:44 -0500 Subject: [PATCH] Update test.js --- test/spec/test.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/spec/test.js b/test/spec/test.js index 42bdad8..714c4da 100644 --- a/test/spec/test.js +++ b/test/spec/test.js @@ -5,11 +5,18 @@ describe('Tests functionality of the localStorage module', function(){ ls = _localStorageService_; spyOn(ls, 'get').andCallFake(function(key){ - return store[key]; + if(store[key].charAt(0) ==="{" || store[key].charAt(0) === "["){ + return angular.fromJson(store[key]); + }else{ + return store[key]; + } }); spyOn(ls, 'set').andCallFake(function(key, val){ - return store[key] = val + ''; + if(typeof val === "object"){ + val = angular.toJson(val); + } + return store[key] = val; }); spyOn(ls, 'clearAll').andCallFake(function(){ @@ -21,5 +28,11 @@ 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 obj = { key: 'val' }; + ls.set('object', obj); + var res = ls.get('object'); + expect(res.key).toBe('val'); + }); });