LP#1626157 EgStoreService unit tests
authorBill Erickson <berickxx@gmail.com>
Fri, 25 May 2018 19:23:25 +0000 (15:23 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 25 May 2018 19:23:25 +0000 (15:23 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/core/org.spec.ts
Open-ILS/src/eg2/src/app/core/store.service.ts
Open-ILS/src/eg2/src/app/core/store.spec.ts [new file with mode: 0644]

index 4a40295..2b2fad6 100644 (file)
@@ -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);
index 822b99f..2062eca 100644 (file)
@@ -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 (file)
index 0000000..0c30fdc
--- /dev/null
@@ -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);
+    });
+
+});
+