Support default values in state manager, so they won't be serialized
Change-Id: I68730ff303fb5e3ed74fca172fe733598037be22
diff --git a/dev/js/spec/stateSpec.js b/dev/js/spec/stateSpec.js
index 5fb6e71..996eca4 100644
--- a/dev/js/spec/stateSpec.js
+++ b/dev/js/spec/stateSpec.js
@@ -181,7 +181,6 @@
expect(serial["glemm"]).toEqual(false);
});
-
it('should serialize correctly', function () {
const el = document.createElement('input');
const sm = stateManagerClass.create(el);
@@ -206,5 +205,31 @@
expect(sm.toString().indexOf("\"z\":\"b\"")).not.toEqual(-1);
expect(sm.toString().indexOf("\"a\":\"d\"")).toEqual(-1);
});
+
+ it('should accept and not serialize default values', function () {
+ const el = document.createElement('input');
+ const sm = stateManagerClass.create(el);
+ expect(sm).toBeTruthy();
+
+ const s1 = sm.newState('test', [1,2,3], 1);
+
+ expect(sm.toString()).toEqual("");
+
+ s1.set(2);
+
+ expect(sm.toString()).toEqual("\"test\":2");
+
+ s1.set(3);
+
+ expect(sm.toString()).toEqual("\"test\":3");
+
+ s1.set(1);
+
+ expect(sm.toString()).toEqual("");
+
+ s1.set(2);
+
+ expect(sm.toString()).toEqual("\"test\":2");
+ });
});
});