From cfa8fcb931f08f50920e4ead49c80df02b9bb0ba Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 25 May 2018 15:23:25 -0400 Subject: [PATCH] LP#1775466 EgStoreService unit tests Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/core/org.spec.ts | 2 +- Open-ILS/src/eg2/src/app/core/store.service.ts | 2 +- Open-ILS/src/eg2/src/app/core/store.spec.ts | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/core/store.spec.ts diff --git a/Open-ILS/src/eg2/src/app/core/org.spec.ts b/Open-ILS/src/eg2/src/app/core/org.spec.ts index 4a4029592b..2b2fad6229 100644 --- a/Open-ILS/src/eg2/src/app/core/org.spec.ts +++ b/Open-ILS/src/eg2/src/app/core/org.spec.ts @@ -18,7 +18,7 @@ describe('EgOrgService', () => { beforeEach(() => { idlService = new EgIdlService(); evtService = new EgEventService(); - storeService = new EgStoreService(); + storeService = new EgStoreService(null /* CookieService */); netService = new EgNetService(evtService); authService = new EgAuthService(evtService, netService, storeService); pcrudService = new EgPcrudService(idlService, netService, authService); diff --git a/Open-ILS/src/eg2/src/app/core/store.service.ts b/Open-ILS/src/eg2/src/app/core/store.service.ts index 822b99f9be..2062eca6d5 100644 --- a/Open-ILS/src/eg2/src/app/core/store.service.ts +++ b/Open-ILS/src/eg2/src/app/core/store.service.ts @@ -52,7 +52,7 @@ export class EgStoreService { if (!isJson) { val = JSON.stringify(val); } - console.log(`${key} ${val}`); + // console.debug(`${key} ${val}`); window.localStorage.setItem(key, val); } diff --git a/Open-ILS/src/eg2/src/app/core/store.spec.ts b/Open-ILS/src/eg2/src/app/core/store.spec.ts new file mode 100644 index 0000000000..0c30fdc7db --- /dev/null +++ b/Open-ILS/src/eg2/src/app/core/store.spec.ts @@ -0,0 +1,22 @@ +import {EgStoreService} from './store.service'; + +describe('EgStoreService', () => { + let service: EgStoreService; + beforeEach(() => { + service = new EgStoreService(null /* CookieService */); + }); + + it('should set/get a localStorage value', () => { + const str = 'hello, world'; + service.setLocalItem('testKey', str); + expect(service.getLocalItem('testKey')).toBe(str); + }); + + it('should set/get a sessionStorage value', () => { + const str = 'hello, world again'; + service.setLocalItem('testKey', str); + expect(service.getLocalItem('testKey')).toBe(str); + }); + +}); + -- 2.11.0