From 7354a44bae904ee3971bd898a62937eac7921c93 Mon Sep 17 00:00:00 2001 From: mwq27 Date: Sat, 2 Nov 2013 09:56:32 -0500 Subject: [PATCH] Update test.js --- test/spec/test.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/test/spec/test.js b/test/spec/test.js index 08cefc6..42bdad8 100644 --- a/test/spec/test.js +++ b/test/spec/test.js @@ -1,12 +1,25 @@ -describe('Module: LocalStorageModule', function() { - 'use strict'; +describe('Tests functionality of the localStorage module', function(){ + beforeEach(module('LocalStorageModule')); + var ls, store = {}; + beforeEach(inject(function(_localStorageService_){ + ls = _localStorageService_; - // Load the Angular module - beforeEach(module('LocalStorageModule')); + spyOn(ls, 'get').andCallFake(function(key){ + return store[key]; + }); - describe('constants', function() { - it('reads the constants', function() { - expect(true).toBe(true); + spyOn(ls, 'set').andCallFake(function(key, val){ + return store[key] = val + ''; + }); + + spyOn(ls, 'clearAll').andCallFake(function(){ + store = {}; + return store; + }); + })); + + it("Should add a value to my local storage", function(){ + ls.set('test', 'MyTest Value'); + expect(ls.get('test')).toBe('MyTest Value'); }); - }); });