Introduce state manager (fixes #119)

Change-Id: Idfd71ea53a898c57e676a197776e2b019ef08561
diff --git a/dev/js/spec/stateSpec.js b/dev/js/spec/stateSpec.js
index 09ab274..286cb1c 100644
--- a/dev/js/spec/stateSpec.js
+++ b/dev/js/spec/stateSpec.js
@@ -1,4 +1,4 @@
-define(['state'], function (stateClass) {
+define(['state','state/manager'], function (stateClass, stateManagerClass) {
 
   describe('KorAP.State', function () {
     it('should be initializable', function () {
@@ -137,4 +137,47 @@
       expect(s.get()).toEqual('mann');
     });
   });
+
+  describe('KorAP.State.Manager', function () {
+
+    const el = document.createElement('input');
+
+    it('should be initializable', function () {
+
+      let sm = stateManagerClass.create(el);
+      expect(sm).toBeTruthy();
+
+      expect(sm.toString()).toEqual("{}");
+    });
+
+
+    it('should be extensible', function () {
+      const sm = stateManagerClass.create(el);
+      expect(sm).toBeTruthy();
+
+      const s1 = sm.newState('test', [1,2,3]);
+      
+      expect(sm.toString()).toEqual("{}");
+
+      s1.set(2);
+
+      expect(sm.toString()).toEqual("{\"test\":2}");
+
+      s1.set(3);
+
+      expect(sm.toString()).toEqual("{\"test\":3}");
+
+      const s2 = sm.newState('glemm', [true,false]);
+
+      let serial = JSON.parse(sm.toString());   
+      expect(serial["test"]).toEqual(3);
+      expect(serial["glemm"]).toBeUndefined();
+
+      s2.set(false);
+
+      serial = JSON.parse(sm.toString());   
+      expect(serial["test"]).toEqual(3);
+      expect(serial["glemm"]).toEqual(false);
+    });
+  });
 });