@fluid-experimental/property-properties 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/containerSerializer.d.ts.map +1 -1
- package/dist/containerSerializer.js +5 -5
- package/dist/containerSerializer.js.map +1 -1
- package/dist/enableValidations.js.map +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/properties/abstractStaticCollectionProperty.d.ts +10 -10
- package/dist/properties/abstractStaticCollectionProperty.d.ts.map +1 -1
- package/dist/properties/abstractStaticCollectionProperty.js +70 -53
- package/dist/properties/abstractStaticCollectionProperty.js.map +1 -1
- package/dist/properties/arrayProperty.d.ts.map +1 -1
- package/dist/properties/arrayProperty.js +152 -103
- package/dist/properties/arrayProperty.js.map +1 -1
- package/dist/properties/baseProperty.d.ts +4 -4
- package/dist/properties/baseProperty.d.ts.map +1 -1
- package/dist/properties/baseProperty.js +69 -47
- package/dist/properties/baseProperty.js.map +1 -1
- package/dist/properties/boolProperty.d.ts.map +1 -1
- package/dist/properties/boolProperty.js +3 -3
- package/dist/properties/boolProperty.js.map +1 -1
- package/dist/properties/containerProperty.d.ts +8 -8
- package/dist/properties/containerProperty.d.ts.map +1 -1
- package/dist/properties/containerProperty.js +33 -26
- package/dist/properties/containerProperty.js.map +1 -1
- package/dist/properties/enumArrayProperty.d.ts.map +1 -1
- package/dist/properties/enumArrayProperty.js +14 -14
- package/dist/properties/enumArrayProperty.js.map +1 -1
- package/dist/properties/enumProperty.d.ts.map +1 -1
- package/dist/properties/enumProperty.js +17 -17
- package/dist/properties/enumProperty.js.map +1 -1
- package/dist/properties/floatProperties.js +4 -4
- package/dist/properties/floatProperties.js.map +1 -1
- package/dist/properties/index.d.ts +23 -23
- package/dist/properties/index.d.ts.map +1 -1
- package/dist/properties/index.js.map +1 -1
- package/dist/properties/indexedCollectionBaseProperty.d.ts.map +1 -1
- package/dist/properties/indexedCollectionBaseProperty.js +47 -37
- package/dist/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/dist/properties/intProperties.d.ts.map +1 -1
- package/dist/properties/intProperties.js +10 -10
- package/dist/properties/intProperties.js.map +1 -1
- package/dist/properties/lazyLoadedProperties.js.map +1 -1
- package/dist/properties/mapProperty.d.ts.map +1 -1
- package/dist/properties/mapProperty.js +21 -17
- package/dist/properties/mapProperty.js.map +1 -1
- package/dist/properties/namedNodeProperty.d.ts.map +1 -1
- package/dist/properties/namedNodeProperty.js +3 -3
- package/dist/properties/namedNodeProperty.js.map +1 -1
- package/dist/properties/namedProperty.d.ts.map +1 -1
- package/dist/properties/namedProperty.js +7 -5
- package/dist/properties/namedProperty.js.map +1 -1
- package/dist/properties/nodeProperty.d.ts.map +1 -1
- package/dist/properties/nodeProperty.js +5 -3
- package/dist/properties/nodeProperty.js.map +1 -1
- package/dist/properties/primitiveTypeCasts.d.ts.map +1 -1
- package/dist/properties/primitiveTypeCasts.js +9 -9
- package/dist/properties/primitiveTypeCasts.js.map +1 -1
- package/dist/properties/referenceArrayProperty.d.ts.map +1 -1
- package/dist/properties/referenceArrayProperty.js +31 -25
- package/dist/properties/referenceArrayProperty.js.map +1 -1
- package/dist/properties/referenceMapProperty.d.ts.map +1 -1
- package/dist/properties/referenceMapProperty.js +18 -18
- package/dist/properties/referenceMapProperty.js.map +1 -1
- package/dist/properties/referenceProperty.d.ts.map +1 -1
- package/dist/properties/referenceProperty.js +33 -29
- package/dist/properties/referenceProperty.js.map +1 -1
- package/dist/properties/setProperty.d.ts.map +1 -1
- package/dist/properties/setProperty.js +31 -29
- package/dist/properties/setProperty.js.map +1 -1
- package/dist/properties/stringProperty.d.ts.map +1 -1
- package/dist/properties/stringProperty.js +56 -40
- package/dist/properties/stringProperty.js.map +1 -1
- package/dist/properties/uintProperties.js +5 -5
- package/dist/properties/uintProperties.js.map +1 -1
- package/dist/properties/valueArrayProperty.d.ts +1 -1
- package/dist/properties/valueArrayProperty.d.ts.map +1 -1
- package/dist/properties/valueArrayProperty.js +30 -29
- package/dist/properties/valueArrayProperty.js.map +1 -1
- package/dist/properties/valueMapProperty.d.ts.map +1 -1
- package/dist/properties/valueMapProperty.js +31 -29
- package/dist/properties/valueMapProperty.js.map +1 -1
- package/dist/properties/valueProperty.d.ts.map +1 -1
- package/dist/properties/valueProperty.js +11 -9
- package/dist/properties/valueProperty.js.map +1 -1
- package/dist/propertyFactory.d.ts.map +1 -1
- package/dist/propertyFactory.js +309 -252
- package/dist/propertyFactory.js.map +1 -1
- package/dist/propertyTemplate.d.ts +17 -17
- package/dist/propertyTemplate.d.ts.map +1 -1
- package/dist/propertyTemplate.js +64 -45
- package/dist/propertyTemplate.js.map +1 -1
- package/dist/propertyTemplateWrapper.d.ts.map +1 -1
- package/dist/propertyTemplateWrapper.js +40 -25
- package/dist/propertyTemplateWrapper.js.map +1 -1
- package/dist/propertyUtils.d.ts.map +1 -1
- package/dist/propertyUtils.js.map +1 -1
- package/dist/test/properties/arrayProperty.spec.js +566 -490
- package/dist/test/properties/arrayProperty.spec.js.map +1 -1
- package/dist/test/properties/baseProperty.spec.js +293 -280
- package/dist/test/properties/baseProperty.spec.js.map +1 -1
- package/dist/test/properties/containerProperty.spec.js +100 -94
- package/dist/test/properties/containerProperty.spec.js.map +1 -1
- package/dist/test/properties/customArrayProperty.spec.js +174 -147
- package/dist/test/properties/customArrayProperty.spec.js.map +1 -1
- package/dist/test/properties/enumArrayProperty.spec.js +67 -63
- package/dist/test/properties/enumArrayProperty.spec.js.map +1 -1
- package/dist/test/properties/enumProperty.spec.js +115 -97
- package/dist/test/properties/enumProperty.spec.js.map +1 -1
- package/dist/test/properties/float32.spec.js +5 -5
- package/dist/test/properties/float32.spec.js.map +1 -1
- package/dist/test/properties/int64ArrayProperty.spec.js +157 -93
- package/dist/test/properties/int64ArrayProperty.spec.js.map +1 -1
- package/dist/test/properties/int64MapProperty.spec.js +185 -166
- package/dist/test/properties/int64MapProperty.spec.js.map +1 -1
- package/dist/test/properties/int64Property.spec.js +109 -109
- package/dist/test/properties/int64Property.spec.js.map +1 -1
- package/dist/test/properties/isLeafNode.spec.js +75 -76
- package/dist/test/properties/isLeafNode.spec.js.map +1 -1
- package/dist/test/properties/mapProperty.spec.js +571 -531
- package/dist/test/properties/mapProperty.spec.js.map +1 -1
- package/dist/test/properties/namedNodeProperty.spec.js +31 -31
- package/dist/test/properties/namedNodeProperty.spec.js.map +1 -1
- package/dist/test/properties/nodeProperty.spec.js +805 -795
- package/dist/test/properties/nodeProperty.spec.js.map +1 -1
- package/dist/test/properties/referenceProperty.spec.js +729 -679
- package/dist/test/properties/referenceProperty.spec.js.map +1 -1
- package/dist/test/properties/relationshipProperty.spec.js +16 -16
- package/dist/test/properties/relationshipProperty.spec.js.map +1 -1
- package/dist/test/properties/setProperty.spec.js +288 -227
- package/dist/test/properties/setProperty.spec.js.map +1 -1
- package/dist/test/properties/stringProperty.spec.js +326 -318
- package/dist/test/properties/stringProperty.spec.js.map +1 -1
- package/dist/test/properties/uint64Property.spec.js +46 -36
- package/dist/test/properties/uint64Property.spec.js.map +1 -1
- package/dist/test/properties/valueMapProperty.spec.js +259 -246
- package/dist/test/properties/valueMapProperty.spec.js.map +1 -1
- package/dist/test/properties/valueProperty.spec.js +49 -43
- package/dist/test/properties/valueProperty.spec.js.map +1 -1
- package/dist/test/propertyFactory.spec.js +2038 -1631
- package/dist/test/propertyFactory.spec.js.map +1 -1
- package/dist/test/propertyTemplateWrapper.spec.js +72 -102
- package/dist/test/propertyTemplateWrapper.spec.js.map +1 -1
- package/dist/test/propertyUtils.spec.js +22 -21
- package/dist/test/propertyUtils.spec.js.map +1 -1
- package/dist/test/reversibleChangeset.spec.js +857 -703
- package/dist/test/reversibleChangeset.spec.js.map +1 -1
- package/dist/test/setup.js +5 -5
- package/dist/test/setup.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/dist/test/utils.spec.js +1334 -1144
- package/dist/test/utils.spec.js.map +1 -1
- package/dist/test/validation/badMissingSemverInTypeid.js +20 -20
- package/dist/test/validation/badMissingSemverInTypeid.js.map +1 -1
- package/dist/test/validation/badPrimitiveTypeid.js +12 -12
- package/dist/test/validation/badPrimitiveTypeid.js.map +1 -1
- package/dist/test/validation/goodColorId.js +91 -91
- package/dist/test/validation/goodColorId.js.map +1 -1
- package/dist/test/validation/goodColorPalette.js +4 -4
- package/dist/test/validation/goodColorPalette.js.map +1 -1
- package/dist/test/validation/goodPointId.js +20 -20
- package/dist/test/validation/goodPointId.js.map +1 -1
- package/dist/test/validation/reversibleChangeSetTestData.js +23841 -2
- package/dist/test/validation/reversibleChangeSetTestData.js.map +1 -1
- package/lib/containerSerializer.d.ts.map +1 -1
- package/lib/containerSerializer.js +5 -5
- package/lib/containerSerializer.js.map +1 -1
- package/lib/enableValidations.js.map +1 -1
- package/lib/index.d.ts +19 -19
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -19
- package/lib/index.js.map +1 -1
- package/lib/properties/abstractStaticCollectionProperty.d.ts +10 -10
- package/lib/properties/abstractStaticCollectionProperty.d.ts.map +1 -1
- package/lib/properties/abstractStaticCollectionProperty.js +70 -53
- package/lib/properties/abstractStaticCollectionProperty.js.map +1 -1
- package/lib/properties/arrayProperty.d.ts.map +1 -1
- package/lib/properties/arrayProperty.js +152 -103
- package/lib/properties/arrayProperty.js.map +1 -1
- package/lib/properties/baseProperty.d.ts +4 -4
- package/lib/properties/baseProperty.d.ts.map +1 -1
- package/lib/properties/baseProperty.js +73 -51
- package/lib/properties/baseProperty.js.map +1 -1
- package/lib/properties/boolProperty.d.ts.map +1 -1
- package/lib/properties/boolProperty.js +3 -3
- package/lib/properties/boolProperty.js.map +1 -1
- package/lib/properties/containerProperty.d.ts +8 -8
- package/lib/properties/containerProperty.d.ts.map +1 -1
- package/lib/properties/containerProperty.js +33 -26
- package/lib/properties/containerProperty.js.map +1 -1
- package/lib/properties/enumArrayProperty.d.ts.map +1 -1
- package/lib/properties/enumArrayProperty.js +14 -14
- package/lib/properties/enumArrayProperty.js.map +1 -1
- package/lib/properties/enumProperty.d.ts.map +1 -1
- package/lib/properties/enumProperty.js +17 -17
- package/lib/properties/enumProperty.js.map +1 -1
- package/lib/properties/floatProperties.js +4 -4
- package/lib/properties/floatProperties.js.map +1 -1
- package/lib/properties/index.d.ts +23 -23
- package/lib/properties/index.d.ts.map +1 -1
- package/lib/properties/index.js +23 -23
- package/lib/properties/index.js.map +1 -1
- package/lib/properties/indexedCollectionBaseProperty.d.ts.map +1 -1
- package/lib/properties/indexedCollectionBaseProperty.js +47 -37
- package/lib/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/lib/properties/intProperties.d.ts.map +1 -1
- package/lib/properties/intProperties.js +10 -10
- package/lib/properties/intProperties.js.map +1 -1
- package/lib/properties/lazyLoadedProperties.js.map +1 -1
- package/lib/properties/mapProperty.d.ts.map +1 -1
- package/lib/properties/mapProperty.js +21 -17
- package/lib/properties/mapProperty.js.map +1 -1
- package/lib/properties/namedNodeProperty.d.ts.map +1 -1
- package/lib/properties/namedNodeProperty.js +3 -3
- package/lib/properties/namedNodeProperty.js.map +1 -1
- package/lib/properties/namedProperty.d.ts.map +1 -1
- package/lib/properties/namedProperty.js +7 -5
- package/lib/properties/namedProperty.js.map +1 -1
- package/lib/properties/nodeProperty.d.ts.map +1 -1
- package/lib/properties/nodeProperty.js +5 -3
- package/lib/properties/nodeProperty.js.map +1 -1
- package/lib/properties/primitiveTypeCasts.d.ts.map +1 -1
- package/lib/properties/primitiveTypeCasts.js +9 -9
- package/lib/properties/primitiveTypeCasts.js.map +1 -1
- package/lib/properties/referenceArrayProperty.d.ts.map +1 -1
- package/lib/properties/referenceArrayProperty.js +31 -25
- package/lib/properties/referenceArrayProperty.js.map +1 -1
- package/lib/properties/referenceMapProperty.d.ts.map +1 -1
- package/lib/properties/referenceMapProperty.js +18 -18
- package/lib/properties/referenceMapProperty.js.map +1 -1
- package/lib/properties/referenceProperty.d.ts.map +1 -1
- package/lib/properties/referenceProperty.js +33 -29
- package/lib/properties/referenceProperty.js.map +1 -1
- package/lib/properties/setProperty.d.ts.map +1 -1
- package/lib/properties/setProperty.js +31 -29
- package/lib/properties/setProperty.js.map +1 -1
- package/lib/properties/stringProperty.d.ts.map +1 -1
- package/lib/properties/stringProperty.js +56 -40
- package/lib/properties/stringProperty.js.map +1 -1
- package/lib/properties/uintProperties.js +5 -5
- package/lib/properties/uintProperties.js.map +1 -1
- package/lib/properties/valueArrayProperty.d.ts +1 -1
- package/lib/properties/valueArrayProperty.d.ts.map +1 -1
- package/lib/properties/valueArrayProperty.js +30 -29
- package/lib/properties/valueArrayProperty.js.map +1 -1
- package/lib/properties/valueMapProperty.d.ts.map +1 -1
- package/lib/properties/valueMapProperty.js +31 -29
- package/lib/properties/valueMapProperty.js.map +1 -1
- package/lib/properties/valueProperty.d.ts.map +1 -1
- package/lib/properties/valueProperty.js +11 -9
- package/lib/properties/valueProperty.js.map +1 -1
- package/lib/propertyFactory.d.ts.map +1 -1
- package/lib/propertyFactory.js +309 -252
- package/lib/propertyFactory.js.map +1 -1
- package/lib/propertyTemplate.d.ts +17 -17
- package/lib/propertyTemplate.d.ts.map +1 -1
- package/lib/propertyTemplate.js +64 -45
- package/lib/propertyTemplate.js.map +1 -1
- package/lib/propertyTemplateWrapper.d.ts.map +1 -1
- package/lib/propertyTemplateWrapper.js +40 -25
- package/lib/propertyTemplateWrapper.js.map +1 -1
- package/lib/propertyUtils.d.ts.map +1 -1
- package/lib/propertyUtils.js.map +1 -1
- package/package.json +28 -28
- package/src/index.d.ts +2750 -2681
|
@@ -7,40 +7,38 @@
|
|
|
7
7
|
* @fileoverview
|
|
8
8
|
* In this file, we will test the map property object described in /src/properties/mapProperty.js
|
|
9
9
|
*/
|
|
10
|
-
const { ChangeSet } = require(
|
|
11
|
-
const { PropertyFactory } = require(
|
|
12
|
-
const { BaseProperty } = require(
|
|
13
|
-
describe(
|
|
10
|
+
const { ChangeSet } = require("@fluid-experimental/property-changeset");
|
|
11
|
+
const { PropertyFactory } = require("../..");
|
|
12
|
+
const { BaseProperty } = require("../..");
|
|
13
|
+
describe("ValueMapProperty", function () {
|
|
14
14
|
var myNode, Uint32Map;
|
|
15
15
|
before(function () {
|
|
16
16
|
// Register a template with a set property for the tests
|
|
17
17
|
var TestPropertyTemplate = {
|
|
18
|
-
typeid:
|
|
19
|
-
inherits: [
|
|
20
|
-
properties: [
|
|
21
|
-
{ id: 'Uint32Map', typeid: 'Uint32', context: 'map' },
|
|
22
|
-
],
|
|
18
|
+
typeid: "autodesk.tests:ValueMapTestPropertyID-1.0.0",
|
|
19
|
+
inherits: ["NamedProperty"],
|
|
20
|
+
properties: [{ id: "Uint32Map", typeid: "Uint32", context: "map" }],
|
|
23
21
|
};
|
|
24
22
|
// Register a template with a set property for the tests
|
|
25
23
|
var AllTypesTestPropertyTemplate = {
|
|
26
|
-
typeid:
|
|
27
|
-
inherits: [
|
|
24
|
+
typeid: "autodesk.tests:AllTypesValueMapTestPropertyID-1.0.0",
|
|
25
|
+
inherits: ["NamedProperty"],
|
|
28
26
|
properties: [
|
|
29
|
-
{ id:
|
|
30
|
-
{ id:
|
|
31
|
-
{ id:
|
|
32
|
-
{ id:
|
|
33
|
-
{ id:
|
|
34
|
-
{ id:
|
|
35
|
-
{ id:
|
|
36
|
-
{ id:
|
|
37
|
-
{ id:
|
|
38
|
-
{ id:
|
|
27
|
+
{ id: "Uint32Map", typeid: "Uint32", context: "map" },
|
|
28
|
+
{ id: "Uint16Map", typeid: "Uint16", context: "map" },
|
|
29
|
+
{ id: "Uint8Map", typeid: "Uint8", context: "map" },
|
|
30
|
+
{ id: "Int32Map", typeid: "Int32", context: "map" },
|
|
31
|
+
{ id: "Int16Map", typeid: "Int16", context: "map" },
|
|
32
|
+
{ id: "Int8Map", typeid: "Int8", context: "map" },
|
|
33
|
+
{ id: "Float64Map", typeid: "Float64", context: "map" },
|
|
34
|
+
{ id: "Float32Map", typeid: "Float32", context: "map" },
|
|
35
|
+
{ id: "StringMap", typeid: "String", context: "map" },
|
|
36
|
+
{ id: "BoolMap", typeid: "Bool", context: "map" },
|
|
39
37
|
],
|
|
40
38
|
};
|
|
41
39
|
PropertyFactory._reregister(TestPropertyTemplate);
|
|
42
40
|
PropertyFactory._reregister(AllTypesTestPropertyTemplate);
|
|
43
|
-
myNode = PropertyFactory.create(
|
|
41
|
+
myNode = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
44
42
|
Uint32Map = myNode._properties.Uint32Map;
|
|
45
43
|
});
|
|
46
44
|
// Helper functions for the test cases
|
|
@@ -51,7 +49,7 @@ describe('ValueMapProperty', function () {
|
|
|
51
49
|
// Inserts a node with a given key (a new one is generated when undefined)
|
|
52
50
|
var insertEntryInRootWithKey = function (key, root) {
|
|
53
51
|
if (key === undefined) {
|
|
54
|
-
key =
|
|
52
|
+
key = "node" + keyCounter++;
|
|
55
53
|
}
|
|
56
54
|
root._properties.Uint32Map.insert(key, keyCounter);
|
|
57
55
|
};
|
|
@@ -61,7 +59,7 @@ describe('ValueMapProperty', function () {
|
|
|
61
59
|
};
|
|
62
60
|
// Returns a functor that will insert a node with a constant key
|
|
63
61
|
var insertEntryInRootWithUnqiueKey = function () {
|
|
64
|
-
var key =
|
|
62
|
+
var key = "node" + keyCounter++;
|
|
65
63
|
return insertEntryInRootWithKey.bind(undefined, key);
|
|
66
64
|
};
|
|
67
65
|
// Removes the first node from the root
|
|
@@ -74,237 +72,240 @@ describe('ValueMapProperty', function () {
|
|
|
74
72
|
var firstKey = root._properties.Uint32Map.getIds()[0];
|
|
75
73
|
root._properties.Uint32Map.set(firstKey, root._properties.Uint32Map.get(firstKey) + 1);
|
|
76
74
|
};
|
|
77
|
-
describe(
|
|
75
|
+
describe("Inherited API Methods", function () {
|
|
78
76
|
var newMap;
|
|
79
77
|
before(function () {
|
|
80
|
-
newMap = PropertyFactory.create(
|
|
78
|
+
newMap = PropertyFactory.create("Int32", "map");
|
|
81
79
|
});
|
|
82
|
-
it(
|
|
83
|
-
newMap.insert(
|
|
84
|
-
newMap.insert(
|
|
85
|
-
expect(newMap.getValues()).to.deep.equal({
|
|
80
|
+
it(".clear should work to remove all entries in the map", function () {
|
|
81
|
+
newMap.insert("one", 1);
|
|
82
|
+
newMap.insert("two", 2);
|
|
83
|
+
expect(newMap.getValues()).to.deep.equal({ one: 1, two: 2 });
|
|
86
84
|
newMap.clear();
|
|
87
85
|
expect(newMap.getValues()).to.deep.equal({});
|
|
88
86
|
});
|
|
89
|
-
it(
|
|
90
|
-
newMap.insert(
|
|
91
|
-
newMap.insert(
|
|
87
|
+
it(".getAsArray should return an array of map values", function () {
|
|
88
|
+
newMap.insert("one", 1);
|
|
89
|
+
newMap.insert("two", 2);
|
|
92
90
|
expect(newMap.getAsArray()).to.deep.equal([1, 2]);
|
|
93
91
|
});
|
|
94
|
-
it(
|
|
95
|
-
newMap.insert(
|
|
96
|
-
newMap.insert(
|
|
97
|
-
expect(newMap.getEntriesReadOnly()).to.deep.equal({
|
|
92
|
+
it("getEntriesReadOnly should work", function () {
|
|
93
|
+
newMap.insert("one", 1);
|
|
94
|
+
newMap.insert("two", 2);
|
|
95
|
+
expect(newMap.getEntriesReadOnly()).to.deep.equal({ one: 1, two: 2 });
|
|
98
96
|
});
|
|
99
|
-
it(
|
|
100
|
-
expect(newMap.getFullTypeid()).to.equal(
|
|
101
|
-
expect(newMap.getFullTypeid(true)).to.equal(
|
|
97
|
+
it(".getFullTypeid should return a string of the typeid with or without collection", function () {
|
|
98
|
+
expect(newMap.getFullTypeid()).to.equal("map<Int32>");
|
|
99
|
+
expect(newMap.getFullTypeid(true)).to.equal("Int32");
|
|
102
100
|
});
|
|
103
|
-
it(
|
|
104
|
-
newMap.insert(
|
|
105
|
-
newMap.insert(
|
|
106
|
-
expect(newMap.getIds()).to.deep.equal([
|
|
101
|
+
it(".getIds should return an array of map keys", function () {
|
|
102
|
+
newMap.insert("one", 1);
|
|
103
|
+
newMap.insert("two", 2);
|
|
104
|
+
expect(newMap.getIds()).to.deep.equal(["one", "two"]);
|
|
107
105
|
});
|
|
108
|
-
it(
|
|
109
|
-
newMap.insert(
|
|
110
|
-
newMap.insert(
|
|
111
|
-
expect(newMap.getValues()).to.deep.equal({
|
|
106
|
+
it(".getValues should return an object", function () {
|
|
107
|
+
newMap.insert("one", 1);
|
|
108
|
+
newMap.insert("two", 2);
|
|
109
|
+
expect(newMap.getValues()).to.deep.equal({ one: 1, two: 2 });
|
|
112
110
|
});
|
|
113
|
-
it(
|
|
114
|
-
newMap.insert(
|
|
115
|
-
newMap.insert(
|
|
116
|
-
expect(newMap.has(
|
|
117
|
-
expect(newMap.has(
|
|
111
|
+
it(".has should return a boolean", function () {
|
|
112
|
+
newMap.insert("one", 1);
|
|
113
|
+
newMap.insert("two", 2);
|
|
114
|
+
expect(newMap.has("two")).to.equal(true);
|
|
115
|
+
expect(newMap.has("three")).to.equal(false);
|
|
118
116
|
});
|
|
119
|
-
it(
|
|
120
|
-
newMap.setValues({
|
|
121
|
-
expect(newMap.get(
|
|
122
|
-
expect(newMap.get(
|
|
117
|
+
it(".setValues should work to set multiple values", function () {
|
|
118
|
+
newMap.setValues({ first: 11, second: 22, third: 33 });
|
|
119
|
+
expect(newMap.get("first")).to.equal(11);
|
|
120
|
+
expect(newMap.get("third")).to.equal(33);
|
|
123
121
|
});
|
|
124
122
|
afterEach(function () {
|
|
125
123
|
newMap.clear();
|
|
126
124
|
});
|
|
127
125
|
});
|
|
128
|
-
describe(
|
|
129
|
-
it(
|
|
126
|
+
describe("Testing creation, assignment and serialization", function () {
|
|
127
|
+
it("should be empty at the beginning", function () {
|
|
130
128
|
expect(Uint32Map.getAsArray()).to.be.empty;
|
|
131
129
|
expect(Uint32Map.getEntriesReadOnly()).to.be.empty;
|
|
132
|
-
expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize({
|
|
133
|
-
expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize({
|
|
134
|
-
});
|
|
135
|
-
it(
|
|
136
|
-
Uint32Map.insert(
|
|
137
|
-
expect(Uint32Map.get(
|
|
138
|
-
Uint32Map.insert(
|
|
139
|
-
expect(Uint32Map.get(
|
|
140
|
-
Uint32Map.insert(
|
|
141
|
-
expect(Uint32Map.get(
|
|
142
|
-
expect(Uint32Map.getEntriesReadOnly()).to.deep.equal({
|
|
130
|
+
expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize({ dirtyOnly: false }))).to.be.ok;
|
|
131
|
+
expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize({ dirtyOnly: true }))).to.be.ok;
|
|
132
|
+
});
|
|
133
|
+
it("should be possible to add entries", function () {
|
|
134
|
+
Uint32Map.insert("value1", 1);
|
|
135
|
+
expect(Uint32Map.get("value1")).to.equal(1);
|
|
136
|
+
Uint32Map.insert("value2", 2);
|
|
137
|
+
expect(Uint32Map.get("value2")).to.equal(2);
|
|
138
|
+
Uint32Map.insert("value3", 3);
|
|
139
|
+
expect(Uint32Map.get("value3")).to.equal(3);
|
|
140
|
+
expect(Uint32Map.getEntriesReadOnly()).to.deep.equal({
|
|
141
|
+
value1: 1,
|
|
142
|
+
value2: 2,
|
|
143
|
+
value3: 3,
|
|
144
|
+
});
|
|
143
145
|
expect(Uint32Map.getAsArray()).to.include(1, 2, 3);
|
|
144
|
-
expect(Uint32Map.has(
|
|
145
|
-
expect(Uint32Map.has(
|
|
146
|
-
expect(Uint32Map.has(
|
|
146
|
+
expect(Uint32Map.has("value1")).to.be.ok;
|
|
147
|
+
expect(Uint32Map.has("value2")).to.be.ok;
|
|
148
|
+
expect(Uint32Map.has("value3")).to.be.ok;
|
|
147
149
|
expect(Uint32Map.serialize()).to.deep.equal({
|
|
148
|
-
insert: {
|
|
150
|
+
insert: { value1: 1, value2: 2, value3: 3 },
|
|
149
151
|
});
|
|
150
152
|
});
|
|
151
|
-
it(
|
|
152
|
-
Uint32Map.remove(
|
|
153
|
-
expect(Uint32Map.has(
|
|
154
|
-
Uint32Map.remove(
|
|
155
|
-
expect(Uint32Map.has(
|
|
156
|
-
Uint32Map.remove(
|
|
157
|
-
expect(Uint32Map.has(
|
|
153
|
+
it("should be possible to remove entries", function () {
|
|
154
|
+
Uint32Map.remove("value1");
|
|
155
|
+
expect(Uint32Map.has("value1")).to.be.not.ok;
|
|
156
|
+
Uint32Map.remove("value2");
|
|
157
|
+
expect(Uint32Map.has("value1")).to.be.not.ok;
|
|
158
|
+
Uint32Map.remove("value3");
|
|
159
|
+
expect(Uint32Map.has("value1")).to.be.not.ok;
|
|
158
160
|
expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize())).to.be.ok;
|
|
159
161
|
});
|
|
160
|
-
it(
|
|
161
|
-
Uint32Map.insert(
|
|
162
|
+
it("a remove followed by an insert should become a modify", function () {
|
|
163
|
+
Uint32Map.insert("value1", 1);
|
|
162
164
|
Uint32Map.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
163
165
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
164
|
-
Uint32Map.remove(
|
|
165
|
-
Uint32Map.insert(
|
|
166
|
-
expect(Uint32Map.serialize({
|
|
167
|
-
modify: {
|
|
166
|
+
Uint32Map.remove("value1");
|
|
167
|
+
Uint32Map.insert("value1", 2);
|
|
168
|
+
expect(Uint32Map.serialize({ dirtyOnly: true })).to.deep.equal({
|
|
169
|
+
modify: { value1: 2 },
|
|
168
170
|
});
|
|
169
171
|
// This should also work for a set operation
|
|
170
|
-
Uint32Map.set(
|
|
171
|
-
expect(Uint32Map.serialize({
|
|
172
|
-
modify: {
|
|
172
|
+
Uint32Map.set("value1", 3);
|
|
173
|
+
expect(Uint32Map.serialize({ dirtyOnly: true })).to.deep.equal({
|
|
174
|
+
modify: { value1: 3 },
|
|
173
175
|
});
|
|
174
176
|
// But setting the same value should give an empty ChangeSet
|
|
175
177
|
Uint32Map.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
176
178
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
177
|
-
Uint32Map.set(
|
|
178
|
-
expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize({
|
|
179
|
+
Uint32Map.set("value1", 3);
|
|
180
|
+
expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize({ dirtyOnly: true }))).to.be.ok;
|
|
179
181
|
// This should be tracked separately for dirtyness and pending changes
|
|
180
182
|
Uint32Map.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
181
183
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
182
|
-
Uint32Map.remove(
|
|
184
|
+
Uint32Map.remove("value1");
|
|
183
185
|
Uint32Map.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY);
|
|
184
|
-
Uint32Map.insert(
|
|
186
|
+
Uint32Map.insert("value1", 2);
|
|
185
187
|
expect(Uint32Map.serialize({
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
})).to.deep.equal({ modify: {
|
|
188
|
+
dirtyOnly: true,
|
|
189
|
+
includeRootTypeid: false,
|
|
190
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE,
|
|
191
|
+
})).to.deep.equal({ modify: { value1: 2 } });
|
|
190
192
|
expect(Uint32Map.serialize({
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
})).to.deep.equal({ insert: {
|
|
195
|
-
});
|
|
196
|
-
it(
|
|
197
|
-
var myInitialStateNode = PropertyFactory.create(
|
|
198
|
-
myInitialStateNode._properties.Uint32Map.insert(
|
|
199
|
-
myInitialStateNode._properties.Uint32Map.insert(
|
|
193
|
+
dirtyOnly: true,
|
|
194
|
+
includeRootTypeid: false,
|
|
195
|
+
dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.DIRTY,
|
|
196
|
+
})).to.deep.equal({ insert: { value1: 2 } });
|
|
197
|
+
});
|
|
198
|
+
it("deserialize should work", function () {
|
|
199
|
+
var myInitialStateNode = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
200
|
+
myInitialStateNode._properties.Uint32Map.insert("value1", 1);
|
|
201
|
+
myInitialStateNode._properties.Uint32Map.insert("value2", 2);
|
|
200
202
|
var initialChangeSet = myInitialStateNode.serialize();
|
|
201
203
|
// Deserialize a copy into a second node and check that the chageset is correct
|
|
202
|
-
var myDeserializeNode1 = PropertyFactory.create(
|
|
204
|
+
var myDeserializeNode1 = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
203
205
|
var changes = myDeserializeNode1.deserialize(initialChangeSet);
|
|
204
206
|
expect(changes).to.deep.equal(initialChangeSet);
|
|
205
207
|
expect(myDeserializeNode1.serialize()).to.deep.equal(myInitialStateNode.serialize());
|
|
206
208
|
myDeserializeNode1.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
207
209
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
208
210
|
// Create a third copy
|
|
209
|
-
var myDeserializeNode2 = PropertyFactory.create(
|
|
211
|
+
var myDeserializeNode2 = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
210
212
|
myDeserializeNode2.deserialize(initialChangeSet);
|
|
211
213
|
myDeserializeNode2.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
212
214
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
213
215
|
myInitialStateNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
214
216
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
215
|
-
myInitialStateNode._properties.Uint32Map.set(
|
|
216
|
-
myInitialStateNode._properties.Uint32Map.remove(
|
|
217
|
-
myInitialStateNode._properties.Uint32Map.insert(
|
|
218
|
-
var changesChangeSet = myInitialStateNode.serialize({
|
|
219
|
-
var fullChangeSet = myInitialStateNode.serialize({
|
|
217
|
+
myInitialStateNode._properties.Uint32Map.set("value1", 2);
|
|
218
|
+
myInitialStateNode._properties.Uint32Map.remove("value2");
|
|
219
|
+
myInitialStateNode._properties.Uint32Map.insert("value3", 3);
|
|
220
|
+
var changesChangeSet = myInitialStateNode.serialize({ dirtyOnly: true });
|
|
221
|
+
var fullChangeSet = myInitialStateNode.serialize({ dirtyOnly: false });
|
|
220
222
|
var reportedChanges = myDeserializeNode1.deserialize(fullChangeSet);
|
|
221
|
-
expect(myDeserializeNode1.serialize({
|
|
223
|
+
expect(myDeserializeNode1.serialize({ dirtyOnly: false })).to.deep.equal(myInitialStateNode.serialize({ dirtyOnly: false }));
|
|
222
224
|
expect(reportedChanges).to.deep.equal(changesChangeSet);
|
|
223
|
-
expect(myDeserializeNode1.serialize({
|
|
225
|
+
expect(myDeserializeNode1.serialize({ dirtyOnly: true })).to.deep.equal(changesChangeSet);
|
|
224
226
|
var deserializeChanges = myDeserializeNode2.deserialize(fullChangeSet);
|
|
225
227
|
expect(deserializeChanges).to.deep.equal(changesChangeSet);
|
|
226
228
|
});
|
|
227
|
-
it(
|
|
228
|
-
var rootNode = PropertyFactory.create(
|
|
229
|
-
rootNode._properties.Uint32Map.insert(
|
|
229
|
+
it("inserting the same key twice should throw an exception", function () {
|
|
230
|
+
var rootNode = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
231
|
+
rootNode._properties.Uint32Map.insert("node1", 1);
|
|
230
232
|
expect(function () {
|
|
231
|
-
rootNode._properties.Uint32Map.insert(
|
|
233
|
+
rootNode._properties.Uint32Map.insert("node1", 2);
|
|
232
234
|
}).to.throw();
|
|
233
235
|
});
|
|
234
|
-
it(
|
|
235
|
-
var rootNode = PropertyFactory.create(
|
|
236
|
-
rootNode._properties.Uint32Map.set(
|
|
237
|
-
rootNode._properties.Uint32Map.set(
|
|
236
|
+
it("set should overwrite existing entry", function () {
|
|
237
|
+
var rootNode = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
238
|
+
rootNode._properties.Uint32Map.set("node1", 0);
|
|
239
|
+
rootNode._properties.Uint32Map.set("node1", 1);
|
|
238
240
|
// the set should overwrite the insert
|
|
239
|
-
expect(rootNode.serialize({
|
|
241
|
+
expect(rootNode.serialize({ dirtyOnly: true })["map<Uint32>"].Uint32Map).to.have.all.keys("insert");
|
|
240
242
|
// Overwriting with the same property shouldn't dirty the node
|
|
241
243
|
rootNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
242
244
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
243
|
-
rootNode._properties.Uint32Map.set(
|
|
244
|
-
expect(ChangeSet.isEmptyChangeSet(rootNode.serialize({
|
|
245
|
+
rootNode._properties.Uint32Map.set("node1", 1);
|
|
246
|
+
expect(ChangeSet.isEmptyChangeSet(rootNode.serialize({ dirtyOnly: true }))).to.be.ok;
|
|
245
247
|
expect(rootNode.isDirty()).to.be.false;
|
|
246
248
|
// Overwriting with a different value should result in a modify
|
|
247
|
-
rootNode._properties.Uint32Map.set(
|
|
248
|
-
expect(rootNode.serialize({
|
|
249
|
-
});
|
|
250
|
-
it(
|
|
251
|
-
var property = PropertyFactory.create(
|
|
252
|
-
property._properties.Uint32Map.set(
|
|
253
|
-
property._properties.Uint32Map.set(
|
|
254
|
-
property._properties.Uint16Map.set(
|
|
255
|
-
property._properties.Uint16Map.set(
|
|
256
|
-
property._properties.Uint8Map.set(
|
|
257
|
-
property._properties.Uint8Map.set(
|
|
258
|
-
property._properties.Int16Map.set(
|
|
259
|
-
property._properties.Int16Map.set(
|
|
260
|
-
property._properties.Int8Map.set(
|
|
261
|
-
property._properties.Int8Map.set(
|
|
262
|
-
property._properties.Float64Map.set(
|
|
263
|
-
property._properties.Float32Map.set(
|
|
264
|
-
property._properties.StringMap.set(
|
|
265
|
-
property._properties.BoolMap.set(
|
|
266
|
-
property._properties.BoolMap.set(
|
|
267
|
-
expect(property._properties.Uint32Map.get(
|
|
268
|
-
expect(property._properties.Uint32Map.get(
|
|
269
|
-
expect(property._properties.Uint32Map.get(
|
|
270
|
-
expect(property._properties.Uint32Map.get(
|
|
271
|
-
expect(property._properties.Uint16Map.get(
|
|
272
|
-
expect(property._properties.Uint16Map.get(
|
|
273
|
-
expect(property._properties.Uint16Map.get(
|
|
274
|
-
expect(property._properties.Uint16Map.get(
|
|
275
|
-
expect(property._properties.Uint8Map.get(
|
|
276
|
-
expect(property._properties.Uint8Map.get(
|
|
277
|
-
expect(property._properties.Uint8Map.get(
|
|
278
|
-
expect(property._properties.Uint8Map.get(
|
|
279
|
-
expect(property._properties.Int16Map.get(
|
|
280
|
-
expect(property._properties.Int16Map.get(
|
|
281
|
-
expect(property._properties.Int16Map.get(
|
|
282
|
-
expect(property._properties.Int16Map.get(
|
|
283
|
-
expect(property._properties.Int8Map.get(
|
|
284
|
-
expect(property._properties.Int8Map.get(
|
|
285
|
-
expect(property._properties.Int8Map.get(
|
|
286
|
-
expect(property._properties.Int8Map.get(
|
|
287
|
-
expect(property._properties.Float32Map.get(
|
|
288
|
-
expect(property._properties.Float64Map.get(
|
|
289
|
-
expect(property._properties.StringMap.get(
|
|
290
|
-
expect(property._properties.BoolMap.get(
|
|
291
|
-
expect(property._properties.BoolMap.get(
|
|
292
|
-
});
|
|
293
|
-
it(
|
|
294
|
-
var myProp = PropertyFactory.create(
|
|
295
|
-
|
|
296
|
-
myProp.insert(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
var prettyStr = '';
|
|
249
|
+
rootNode._properties.Uint32Map.set("node1", 2);
|
|
250
|
+
expect(rootNode.serialize({ dirtyOnly: true })["map<Uint32>"].Uint32Map).to.have.all.keys("modify");
|
|
251
|
+
});
|
|
252
|
+
it("casting should work as expected", function () {
|
|
253
|
+
var property = PropertyFactory.create("autodesk.tests:AllTypesValueMapTestPropertyID-1.0.0");
|
|
254
|
+
property._properties.Uint32Map.set("tooLarge", 1e20);
|
|
255
|
+
property._properties.Uint32Map.set("negative", -1);
|
|
256
|
+
property._properties.Uint16Map.set("tooLarge", 1e20);
|
|
257
|
+
property._properties.Uint16Map.set("negative", -1);
|
|
258
|
+
property._properties.Uint8Map.set("tooLarge", 1e20);
|
|
259
|
+
property._properties.Uint8Map.set("negative", -1);
|
|
260
|
+
property._properties.Int16Map.set("tooSmall", -32769);
|
|
261
|
+
property._properties.Int16Map.set("tooLarge", 32768);
|
|
262
|
+
property._properties.Int8Map.set("tooSmall", -129);
|
|
263
|
+
property._properties.Int8Map.set("tooLarge", 128);
|
|
264
|
+
property._properties.Float64Map.set("value", 1e300);
|
|
265
|
+
property._properties.Float32Map.set("tooLarge", 1e300);
|
|
266
|
+
property._properties.StringMap.set("value", "test");
|
|
267
|
+
property._properties.BoolMap.set("true", 1);
|
|
268
|
+
property._properties.BoolMap.set("false", 0);
|
|
269
|
+
expect(property._properties.Uint32Map.get("tooLarge")).to.be.below(Math.pow(2, 32));
|
|
270
|
+
expect(property._properties.Uint32Map.get("tooLarge")).to.be.above(-1);
|
|
271
|
+
expect(property._properties.Uint32Map.get("negative")).to.be.below(Math.pow(2, 32));
|
|
272
|
+
expect(property._properties.Uint32Map.get("negative")).to.be.above(-1);
|
|
273
|
+
expect(property._properties.Uint16Map.get("tooLarge")).to.be.below(Math.pow(2, 16));
|
|
274
|
+
expect(property._properties.Uint16Map.get("tooLarge")).to.be.above(-1);
|
|
275
|
+
expect(property._properties.Uint16Map.get("negative")).to.be.below(Math.pow(2, 16));
|
|
276
|
+
expect(property._properties.Uint16Map.get("negative")).to.be.above(-1);
|
|
277
|
+
expect(property._properties.Uint8Map.get("tooLarge")).to.be.below(Math.pow(2, 8));
|
|
278
|
+
expect(property._properties.Uint8Map.get("tooLarge")).to.be.above(-1);
|
|
279
|
+
expect(property._properties.Uint8Map.get("negative")).to.be.below(Math.pow(2, 8));
|
|
280
|
+
expect(property._properties.Uint8Map.get("negative")).to.be.above(-1);
|
|
281
|
+
expect(property._properties.Int16Map.get("tooLarge")).to.be.below(32768);
|
|
282
|
+
expect(property._properties.Int16Map.get("tooLarge")).to.be.above(-32769);
|
|
283
|
+
expect(property._properties.Int16Map.get("tooSmall")).to.be.below(32768);
|
|
284
|
+
expect(property._properties.Int16Map.get("tooSmall")).to.be.above(-32769);
|
|
285
|
+
expect(property._properties.Int8Map.get("tooLarge")).to.be.below(128);
|
|
286
|
+
expect(property._properties.Int8Map.get("tooLarge")).to.be.above(-129);
|
|
287
|
+
expect(property._properties.Int8Map.get("tooSmall")).to.be.below(128);
|
|
288
|
+
expect(property._properties.Int8Map.get("tooSmall")).to.be.above(-129);
|
|
289
|
+
expect(property._properties.Float32Map.get("tooLarge")).to.equal(Infinity);
|
|
290
|
+
expect(property._properties.Float64Map.get("value")).to.equal(1e300);
|
|
291
|
+
expect(property._properties.StringMap.get("value")).to.equal("test");
|
|
292
|
+
expect(property._properties.BoolMap.get("true")).to.equal(true);
|
|
293
|
+
expect(property._properties.BoolMap.get("false")).to.equal(false);
|
|
294
|
+
});
|
|
295
|
+
it("prettyPrint should work", function () {
|
|
296
|
+
var myProp = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0")
|
|
297
|
+
._properties.Uint32Map;
|
|
298
|
+
myProp.insert("value1", 1);
|
|
299
|
+
myProp.insert("value2", 2);
|
|
300
|
+
var expectedPrettyStr = "Uint32Map (Map of Uint32):\n" + " value1: 1\n" + " value2: 2\n";
|
|
301
|
+
var prettyStr = "";
|
|
301
302
|
myProp.prettyPrint(function (str) {
|
|
302
|
-
prettyStr += str +
|
|
303
|
+
prettyStr += str + "\n";
|
|
303
304
|
});
|
|
304
305
|
expect(prettyStr).to.equal(expectedPrettyStr);
|
|
305
306
|
});
|
|
306
307
|
});
|
|
307
|
-
describe(
|
|
308
|
+
describe("squashing", function () {
|
|
308
309
|
//
|
|
309
310
|
// Helper function which takes a sequence of callbacks that are suceessively executed
|
|
310
311
|
// and the changes applied by the callbacks are separately tracked and squashed in a
|
|
@@ -315,7 +316,7 @@ describe('ValueMapProperty', function () {
|
|
|
315
316
|
//
|
|
316
317
|
var testChangeSetSquashing = function (in_options) {
|
|
317
318
|
resetKeyCounter();
|
|
318
|
-
var testProperty = PropertyFactory.create(
|
|
319
|
+
var testProperty = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
319
320
|
var callbacks = in_options.callbacks;
|
|
320
321
|
if (in_options.pre) {
|
|
321
322
|
in_options.pre(testProperty);
|
|
@@ -327,7 +328,7 @@ describe('ValueMapProperty', function () {
|
|
|
327
328
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
328
329
|
for (var i = 0; i < callbacks.length; i++) {
|
|
329
330
|
callbacks[i](testProperty);
|
|
330
|
-
var changes = testProperty.serialize({
|
|
331
|
+
var changes = testProperty.serialize({ dirtyOnly: true });
|
|
331
332
|
testProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
332
333
|
BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE);
|
|
333
334
|
squashedChangeset.applyChangeSet(changes);
|
|
@@ -336,25 +337,38 @@ describe('ValueMapProperty', function () {
|
|
|
336
337
|
in_options.post(squashedChangeset.getSerializedChangeSet());
|
|
337
338
|
}
|
|
338
339
|
initialChangeset.applyChangeSet(squashedChangeset.getSerializedChangeSet());
|
|
339
|
-
expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({
|
|
340
|
+
expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({ dirtyOnly: false }));
|
|
340
341
|
};
|
|
341
|
-
it(
|
|
342
|
-
testChangeSetSquashing({
|
|
342
|
+
it("should work for multiple independent inserts", function () {
|
|
343
|
+
testChangeSetSquashing({
|
|
344
|
+
callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot],
|
|
345
|
+
});
|
|
343
346
|
});
|
|
344
|
-
it(
|
|
347
|
+
it("should work for inserts followed by removes", function () {
|
|
345
348
|
testChangeSetSquashing({
|
|
346
|
-
callbacks: [
|
|
349
|
+
callbacks: [
|
|
350
|
+
insertNodeInRoot,
|
|
351
|
+
insertNodeInRoot,
|
|
352
|
+
removeFirstNodeInRoot,
|
|
353
|
+
removeFirstNodeInRoot,
|
|
354
|
+
],
|
|
347
355
|
post: function (changeset) {
|
|
348
356
|
expect(changeset).to.be.empty;
|
|
349
357
|
},
|
|
350
358
|
});
|
|
351
359
|
});
|
|
352
|
-
it(
|
|
360
|
+
it("of inserts and modifies should work", function () {
|
|
353
361
|
testChangeSetSquashing({
|
|
354
|
-
callbacks: [
|
|
362
|
+
callbacks: [
|
|
363
|
+
insertNodeInRoot,
|
|
364
|
+
insertNodeInRoot,
|
|
365
|
+
insertNodeInRoot,
|
|
366
|
+
modifyEntry,
|
|
367
|
+
modifyEntry,
|
|
368
|
+
],
|
|
355
369
|
});
|
|
356
370
|
});
|
|
357
|
-
it(
|
|
371
|
+
it("an insert, modify and a remove should give an empty changeset", function () {
|
|
358
372
|
testChangeSetSquashing({
|
|
359
373
|
callbacks: [insertNodeInRoot, modifyEntry, modifyEntry, removeFirstNodeInRoot],
|
|
360
374
|
post: function (changeset) {
|
|
@@ -362,50 +376,50 @@ describe('ValueMapProperty', function () {
|
|
|
362
376
|
},
|
|
363
377
|
});
|
|
364
378
|
});
|
|
365
|
-
it(
|
|
379
|
+
it("should work for modifies after an already existing insert", function () {
|
|
366
380
|
testChangeSetSquashing({
|
|
367
381
|
pre: insertNodeInRoot,
|
|
368
382
|
callbacks: [modifyEntry, modifyEntry],
|
|
369
383
|
});
|
|
370
384
|
});
|
|
371
|
-
it(
|
|
385
|
+
it("of modify and remove after an already existing insert should work", function () {
|
|
372
386
|
testChangeSetSquashing({
|
|
373
387
|
pre: insertNodeInRoot,
|
|
374
388
|
callbacks: [modifyEntry, removeFirstNodeInRoot],
|
|
375
389
|
post: function (changeset) {
|
|
376
|
-
expect(changeset[
|
|
390
|
+
expect(changeset["map<Uint32>"].Uint32Map).to.have.all.keys("remove");
|
|
377
391
|
},
|
|
378
392
|
});
|
|
379
393
|
});
|
|
380
|
-
it(
|
|
394
|
+
it("of remove and insert should result in modify", function () {
|
|
381
395
|
// Create two nodes with the same GUID
|
|
382
396
|
testChangeSetSquashing({
|
|
383
397
|
pre: function (root) {
|
|
384
|
-
root._properties.Uint32Map.insert(
|
|
398
|
+
root._properties.Uint32Map.insert("node1", 1);
|
|
385
399
|
},
|
|
386
400
|
callbacks: [
|
|
387
401
|
removeFirstNodeInRoot,
|
|
388
402
|
function (root) {
|
|
389
|
-
root._properties.Uint32Map.insert(
|
|
403
|
+
root._properties.Uint32Map.insert("node1", 2);
|
|
390
404
|
},
|
|
391
405
|
],
|
|
392
406
|
post: function (changeset) {
|
|
393
|
-
expect(changeset[
|
|
407
|
+
expect(changeset["map<Uint32>"].Uint32Map).to.have.all.keys("modify");
|
|
394
408
|
},
|
|
395
409
|
});
|
|
396
410
|
});
|
|
397
411
|
});
|
|
398
|
-
describe(
|
|
412
|
+
describe("Rebasing", function () {
|
|
399
413
|
var testRebasing = function (in_options) {
|
|
400
414
|
// Prepare the initial state
|
|
401
|
-
var baseProperty1 = PropertyFactory.create(
|
|
415
|
+
var baseProperty1 = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
402
416
|
if (in_options.prepare) {
|
|
403
417
|
in_options.prepare(baseProperty1);
|
|
404
418
|
}
|
|
405
419
|
// Create two copies of this state
|
|
406
|
-
var baseProperty2 = PropertyFactory.create(
|
|
420
|
+
var baseProperty2 = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
407
421
|
baseProperty2.deserialize(baseProperty1.serialize());
|
|
408
|
-
var baseProperty3 = PropertyFactory.create(
|
|
422
|
+
var baseProperty3 = PropertyFactory.create("autodesk.tests:ValueMapTestPropertyID-1.0.0");
|
|
409
423
|
baseProperty3.deserialize(baseProperty1.serialize());
|
|
410
424
|
// Make sure the states are clear
|
|
411
425
|
baseProperty1.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY |
|
|
@@ -423,8 +437,8 @@ describe('ValueMapProperty', function () {
|
|
|
423
437
|
in_options.op2(baseProperty2);
|
|
424
438
|
}
|
|
425
439
|
// Get the ChangeSets
|
|
426
|
-
var changeSet1 = new ChangeSet(baseProperty1.serialize({
|
|
427
|
-
var changeSet2 = baseProperty2.serialize({
|
|
440
|
+
var changeSet1 = new ChangeSet(baseProperty1.serialize({ dirtyOnly: true }));
|
|
441
|
+
var changeSet2 = baseProperty2.serialize({ dirtyOnly: true });
|
|
428
442
|
// Perform the actual rebase
|
|
429
443
|
var conflicts = [];
|
|
430
444
|
changeSet1._rebaseChangeSet(changeSet2, conflicts);
|
|
@@ -439,55 +453,55 @@ describe('ValueMapProperty', function () {
|
|
|
439
453
|
if (in_options.op2) {
|
|
440
454
|
in_options.op2(baseProperty3);
|
|
441
455
|
}
|
|
442
|
-
var finalChangeSet = baseProperty3.serialize({
|
|
456
|
+
var finalChangeSet = baseProperty3.serialize({ dirtyOnly: false });
|
|
443
457
|
expect(finalChangeSet).to.be.deep.equal(combinedChangeSet.getSerializedChangeSet());
|
|
444
458
|
}
|
|
445
459
|
if (in_options.checkResult) {
|
|
446
460
|
in_options.checkResult(conflicts, changeSet2, combinedChangeSet);
|
|
447
461
|
}
|
|
448
462
|
};
|
|
449
|
-
it(
|
|
463
|
+
it("with a NOP should be possible", function () {
|
|
450
464
|
testRebasing({
|
|
451
465
|
op2: insertEntryInRootWithUnqiueKey(),
|
|
452
466
|
compareToSequential: true,
|
|
453
467
|
});
|
|
454
468
|
});
|
|
455
|
-
it(
|
|
469
|
+
it("with independent inserts should be possible", function () {
|
|
456
470
|
testRebasing({
|
|
457
471
|
op1: insertEntryInRootWithUnqiueKey(),
|
|
458
472
|
op2: insertEntryInRootWithUnqiueKey(),
|
|
459
473
|
compareToSequential: true,
|
|
460
474
|
});
|
|
461
475
|
});
|
|
462
|
-
it(
|
|
476
|
+
it("with independent removes should be possible", function () {
|
|
463
477
|
testRebasing({
|
|
464
478
|
prepare: function (root) {
|
|
465
|
-
root._properties.Uint32Map.insert(
|
|
466
|
-
root._properties.Uint32Map.insert(
|
|
479
|
+
root._properties.Uint32Map.insert("entry1", 1);
|
|
480
|
+
root._properties.Uint32Map.insert("entry2", 2);
|
|
467
481
|
},
|
|
468
482
|
op1: function (root) {
|
|
469
|
-
root._properties.Uint32Map.remove(
|
|
483
|
+
root._properties.Uint32Map.remove("entry1");
|
|
470
484
|
},
|
|
471
485
|
op2: function (root) {
|
|
472
|
-
root._properties.Uint32Map.remove(
|
|
486
|
+
root._properties.Uint32Map.remove("entry2");
|
|
473
487
|
},
|
|
474
488
|
compareToSequential: true,
|
|
475
489
|
});
|
|
476
490
|
});
|
|
477
|
-
it(
|
|
491
|
+
it("with a modify and a remove should possible", function () {
|
|
478
492
|
testRebasing({
|
|
479
493
|
prepare: function (root) {
|
|
480
|
-
root._properties.Uint32Map.insert(
|
|
494
|
+
root._properties.Uint32Map.insert("entry1", 1);
|
|
481
495
|
},
|
|
482
496
|
op1: modifyEntry,
|
|
483
497
|
op2: removeFirstNodeInRoot,
|
|
484
498
|
compareToSequential: true,
|
|
485
499
|
});
|
|
486
500
|
});
|
|
487
|
-
it(
|
|
501
|
+
it("with a remove and a modify should possible", function () {
|
|
488
502
|
testRebasing({
|
|
489
503
|
prepare: function (root) {
|
|
490
|
-
root._properties.Uint32Map.insert(
|
|
504
|
+
root._properties.Uint32Map.insert("entry1", 1);
|
|
491
505
|
},
|
|
492
506
|
op1: removeFirstNodeInRoot,
|
|
493
507
|
op2: modifyEntry,
|
|
@@ -495,21 +509,21 @@ describe('ValueMapProperty', function () {
|
|
|
495
509
|
checkResult: function (conflicts, changeSet) {
|
|
496
510
|
expect(conflicts).to.have.length(1);
|
|
497
511
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE);
|
|
498
|
-
expect(conflicts[0].path).to.be.equal(
|
|
512
|
+
expect(conflicts[0].path).to.be.equal("Uint32Map[entry1]");
|
|
499
513
|
expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok;
|
|
500
514
|
},
|
|
501
515
|
});
|
|
502
516
|
});
|
|
503
|
-
it(
|
|
517
|
+
it("with two compatible removes should be possible", function () {
|
|
504
518
|
testRebasing({
|
|
505
519
|
prepare: function (root) {
|
|
506
|
-
root._properties.Uint32Map.insert(
|
|
520
|
+
root._properties.Uint32Map.insert("entry1", 1);
|
|
507
521
|
},
|
|
508
522
|
op1: function (root) {
|
|
509
|
-
root._properties.Uint32Map.remove(
|
|
523
|
+
root._properties.Uint32Map.remove("entry1");
|
|
510
524
|
},
|
|
511
525
|
op2: function (root) {
|
|
512
|
-
root._properties.Uint32Map.remove(
|
|
526
|
+
root._properties.Uint32Map.remove("entry1");
|
|
513
527
|
},
|
|
514
528
|
compareToSequential: false,
|
|
515
529
|
checkResult: function (conflicts, changeSet) {
|
|
@@ -517,79 +531,78 @@ describe('ValueMapProperty', function () {
|
|
|
517
531
|
},
|
|
518
532
|
});
|
|
519
533
|
});
|
|
520
|
-
it(
|
|
534
|
+
it("with two conflicting modifies should be possible and report a conflict", function () {
|
|
521
535
|
testRebasing({
|
|
522
536
|
prepare: function (root) {
|
|
523
|
-
root._properties.Uint32Map.insert(
|
|
537
|
+
root._properties.Uint32Map.insert("entry1", 1);
|
|
524
538
|
},
|
|
525
539
|
op1: function (root) {
|
|
526
|
-
root._properties.Uint32Map.set(
|
|
540
|
+
root._properties.Uint32Map.set("entry1", 2);
|
|
527
541
|
},
|
|
528
542
|
op2: function (root) {
|
|
529
|
-
root._properties.Uint32Map.set(
|
|
543
|
+
root._properties.Uint32Map.set("entry1", 3);
|
|
530
544
|
},
|
|
531
545
|
compareToSequential: true,
|
|
532
546
|
checkResult: function (conflicts, changeSet) {
|
|
533
547
|
expect(conflicts).to.have.length(1);
|
|
534
548
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
535
|
-
expect(conflicts[0].path).to.be.equal(
|
|
549
|
+
expect(conflicts[0].path).to.be.equal("Uint32Map[entry1]");
|
|
536
550
|
},
|
|
537
551
|
});
|
|
538
552
|
});
|
|
539
|
-
it(
|
|
553
|
+
it("with modify followed by remove+insert should be a conflicting set", function () {
|
|
540
554
|
testRebasing({
|
|
541
555
|
prepare: function (root) {
|
|
542
|
-
root._properties.Uint32Map.insert(
|
|
556
|
+
root._properties.Uint32Map.insert("entry1", 1);
|
|
543
557
|
},
|
|
544
558
|
op1: modifyEntry,
|
|
545
559
|
op2: function (root) {
|
|
546
|
-
root._properties.Uint32Map.remove(
|
|
547
|
-
root._properties.Uint32Map.insert(
|
|
560
|
+
root._properties.Uint32Map.remove("entry1");
|
|
561
|
+
root._properties.Uint32Map.insert("entry1", 2);
|
|
548
562
|
},
|
|
549
563
|
compareToSequential: true,
|
|
550
564
|
checkResult: function (conflicts, changeSet) {
|
|
551
565
|
expect(conflicts).to.have.length(1);
|
|
552
566
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
553
|
-
expect(conflicts[0].path).to.be.equal(
|
|
567
|
+
expect(conflicts[0].path).to.be.equal("Uint32Map[entry1]");
|
|
554
568
|
},
|
|
555
569
|
});
|
|
556
570
|
});
|
|
557
|
-
it(
|
|
571
|
+
it("with remove+insert followed by modify should be a conflicting set", function () {
|
|
558
572
|
testRebasing({
|
|
559
573
|
prepare: function (root) {
|
|
560
|
-
root._properties.Uint32Map.insert(
|
|
574
|
+
root._properties.Uint32Map.insert("entry1", 1);
|
|
561
575
|
},
|
|
562
576
|
op1: function (root) {
|
|
563
|
-
root._properties.Uint32Map.remove(
|
|
564
|
-
root._properties.Uint32Map.insert(
|
|
577
|
+
root._properties.Uint32Map.remove("entry1");
|
|
578
|
+
root._properties.Uint32Map.insert("entry1", 2);
|
|
565
579
|
},
|
|
566
580
|
op2: function (root) {
|
|
567
|
-
root._properties.Uint32Map.set(
|
|
581
|
+
root._properties.Uint32Map.set("entry1", 3);
|
|
568
582
|
},
|
|
569
583
|
compareToSequential: true,
|
|
570
584
|
checkResult: function (conflicts, changeSet) {
|
|
571
585
|
expect(conflicts).to.have.length(1);
|
|
572
586
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
573
|
-
expect(conflicts[0].path).to.be.equal(
|
|
587
|
+
expect(conflicts[0].path).to.be.equal("Uint32Map[entry1]");
|
|
574
588
|
},
|
|
575
589
|
});
|
|
576
590
|
});
|
|
577
|
-
it(
|
|
591
|
+
it("with conflicting inserts should report conflict", function () {
|
|
578
592
|
testRebasing({
|
|
579
|
-
prepare: function (root) {
|
|
580
|
-
},
|
|
593
|
+
prepare: function (root) { },
|
|
581
594
|
op1: function (root) {
|
|
582
|
-
root._properties.Uint32Map.insert(
|
|
595
|
+
root._properties.Uint32Map.insert("entry1", 1);
|
|
583
596
|
},
|
|
584
597
|
op2: function (root) {
|
|
585
|
-
root._properties.Uint32Map.insert(
|
|
598
|
+
root._properties.Uint32Map.insert("entry1", 2);
|
|
586
599
|
},
|
|
587
600
|
compareToSequential: false,
|
|
588
601
|
checkResult: function (conflicts, changeSet) {
|
|
589
|
-
expect(changeSet[
|
|
602
|
+
expect(changeSet["map<Uint32>"].Uint32Map).to.have.all.keys("modify");
|
|
590
603
|
expect(conflicts).to.have.length(1);
|
|
591
604
|
expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET);
|
|
592
|
-
expect(conflicts[0].path).to.be.equal(
|
|
605
|
+
expect(conflicts[0].path).to.be.equal("Uint32Map[entry1]");
|
|
593
606
|
},
|
|
594
607
|
});
|
|
595
608
|
});
|