@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,27 +7,27 @@
|
|
|
7
7
|
* described in /src/properties/baseProperty.js
|
|
8
8
|
*/
|
|
9
9
|
var PropertyFactory, ChangeSet, MSG, BaseProperty;
|
|
10
|
-
describe(
|
|
10
|
+
describe("BaseProperty", function () {
|
|
11
11
|
/**
|
|
12
12
|
* Get all the objects we need in this test here.
|
|
13
13
|
*/
|
|
14
14
|
before(function () {
|
|
15
|
-
PropertyFactory = require(
|
|
16
|
-
ChangeSet = require(
|
|
17
|
-
MSG = require(
|
|
18
|
-
BaseProperty = require(
|
|
15
|
+
PropertyFactory = require("../..").PropertyFactory;
|
|
16
|
+
ChangeSet = require("@fluid-experimental/property-changeset").ChangeSet;
|
|
17
|
+
MSG = require("@fluid-experimental/property-common").constants.MSG;
|
|
18
|
+
BaseProperty = require("../..").BaseProperty;
|
|
19
19
|
var TestPropertyObject = {
|
|
20
|
-
typeid:
|
|
20
|
+
typeid: "autodesk.tests:property.with.special.characters-1.0.0",
|
|
21
21
|
properties: [
|
|
22
|
-
{ id:
|
|
23
|
-
{ id:
|
|
24
|
-
{ id: 'test"property"', typeid:
|
|
22
|
+
{ id: "simple_property", typeid: "String" },
|
|
23
|
+
{ id: "test.property", typeid: "String" },
|
|
24
|
+
{ id: 'test"property"', typeid: "String" },
|
|
25
25
|
{
|
|
26
|
-
id:
|
|
26
|
+
id: "test[property]",
|
|
27
|
+
properties: [
|
|
27
28
|
{
|
|
28
|
-
id:
|
|
29
|
-
|
|
30
|
-
],
|
|
29
|
+
id: ".property.",
|
|
30
|
+
properties: [{ id: "test", typeid: "String" }],
|
|
31
31
|
},
|
|
32
32
|
],
|
|
33
33
|
},
|
|
@@ -35,109 +35,117 @@ describe('BaseProperty', function () {
|
|
|
35
35
|
};
|
|
36
36
|
PropertyFactory._reregister(TestPropertyObject);
|
|
37
37
|
});
|
|
38
|
-
describe(
|
|
39
|
-
it(
|
|
40
|
-
var myProp = PropertyFactory.create(
|
|
41
|
-
myProp._properties[
|
|
42
|
-
myProp._properties['test"property"'].value =
|
|
43
|
-
myProp._properties[
|
|
38
|
+
describe("Serializing a BaseProperty with special characters", function () {
|
|
39
|
+
it("should be possible to serialize a property with special characters", function () {
|
|
40
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
41
|
+
myProp._properties["test.property"].value = "a";
|
|
42
|
+
myProp._properties['test"property"'].value = "b";
|
|
43
|
+
myProp._properties["test[property]"][".property."]["test"].value = "c";
|
|
44
44
|
var serialized = myProp._serialize(false);
|
|
45
|
-
var myProp2 = PropertyFactory.create(
|
|
45
|
+
var myProp2 = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
46
46
|
myProp2.deserialize(serialized);
|
|
47
|
-
expect(myProp2._properties[
|
|
48
|
-
expect(myProp2._properties['test"property"'].value).to.equal(
|
|
49
|
-
expect(myProp2._properties[
|
|
47
|
+
expect(myProp2._properties["test.property"].value).to.equal("a");
|
|
48
|
+
expect(myProp2._properties['test"property"'].value).to.equal("b");
|
|
49
|
+
expect(myProp2._properties["test[property]"][".property."]["test"].value).to.equal("c");
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
-
describe(
|
|
52
|
+
describe("Get should work", function () {
|
|
53
53
|
// Test whether .get accepts the correct parameters
|
|
54
|
-
it(
|
|
55
|
-
var myProp = PropertyFactory.create(
|
|
54
|
+
it("should accept an id (string) or an array of ids", function () {
|
|
55
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
56
56
|
var correctArrayFn = function () {
|
|
57
|
-
myProp.get([
|
|
57
|
+
myProp.get(["test"]);
|
|
58
58
|
};
|
|
59
59
|
var correctStringFn = function () {
|
|
60
|
-
myProp.get(
|
|
60
|
+
myProp.get("test");
|
|
61
61
|
};
|
|
62
62
|
expect(correctArrayFn).to.not.throw();
|
|
63
63
|
expect(correctStringFn).to.not.throw();
|
|
64
64
|
});
|
|
65
65
|
// .get(['test1','test2']) === .get('test1').get('test2')
|
|
66
|
-
it(
|
|
67
|
-
var myProp = PropertyFactory.create(
|
|
68
|
-
expect(myProp.get([
|
|
69
|
-
});
|
|
70
|
-
it(
|
|
71
|
-
var myProp = PropertyFactory.create(
|
|
72
|
-
expect(myProp.get([
|
|
73
|
-
});
|
|
74
|
-
it(
|
|
75
|
-
var myProp = PropertyFactory.create(
|
|
76
|
-
expect(myProp.get([
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
BaseProperty.PATH_TOKENS.UP,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
it("when an array is passed, it should do a .get for each id in the array", function () {
|
|
67
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
68
|
+
expect(myProp.get(["test[property]", ".property.", "test"])).to.equal(myProp.get("test[property]").get(".property.").get("test"));
|
|
69
|
+
});
|
|
70
|
+
it("when an array is passed with a bad path, it should return undefined", function () {
|
|
71
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
72
|
+
expect(myProp.get(["wrong path", ".property", "test"])).to.be.undefined;
|
|
73
|
+
});
|
|
74
|
+
it("should work with raise level path tokens", function () {
|
|
75
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
76
|
+
expect(myProp.get([
|
|
77
|
+
"test[property]",
|
|
78
|
+
".property.",
|
|
79
|
+
BaseProperty.PATH_TOKENS.UP,
|
|
80
|
+
".property.",
|
|
81
|
+
"test",
|
|
82
|
+
])).to.deep.equal(myProp.get("test[property]").get(".property.").get("test"));
|
|
83
|
+
expect(myProp.get([
|
|
84
|
+
"test[property]",
|
|
85
|
+
".property.",
|
|
86
|
+
BaseProperty.PATH_TOKENS.UP,
|
|
87
|
+
BaseProperty.PATH_TOKENS.UP,
|
|
88
|
+
"simple_property",
|
|
89
|
+
])).to.deep.equal(myProp.get("simple_property"));
|
|
90
|
+
});
|
|
91
|
+
it("should work with path root tokens", function () {
|
|
92
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
84
93
|
expect(myProp.get([BaseProperty.PATH_TOKENS.ROOT])).to.equal(myProp);
|
|
85
|
-
expect(myProp.get([BaseProperty.PATH_TOKENS.ROOT,
|
|
86
|
-
|
|
87
|
-
expect(myProp.get('test[property]').get([BaseProperty.PATH_TOKENS.ROOT])).to.equal(myProp);
|
|
94
|
+
expect(myProp.get([BaseProperty.PATH_TOKENS.ROOT, "simple_property"])).to.equal(myProp.get("simple_property"));
|
|
95
|
+
expect(myProp.get("test[property]").get([BaseProperty.PATH_TOKENS.ROOT])).to.equal(myProp);
|
|
88
96
|
});
|
|
89
97
|
});
|
|
90
|
-
describe(
|
|
91
|
-
it(
|
|
92
|
-
var myProp = PropertyFactory.create(
|
|
93
|
-
myProp._properties[
|
|
94
|
-
var myValue = myProp.getValue([
|
|
95
|
-
expect(myValue).to.equal(
|
|
96
|
-
});
|
|
97
|
-
it(
|
|
98
|
-
var myProp = PropertyFactory.create(
|
|
99
|
-
myProp.get([
|
|
100
|
-
expect(myProp.getValue([
|
|
101
|
-
});
|
|
102
|
-
it(
|
|
103
|
-
var myProp = PropertyFactory.create(
|
|
98
|
+
describe("GetValue should work", function () {
|
|
99
|
+
it("should return the value of a primitive property", function () {
|
|
100
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
101
|
+
myProp._properties["test.property"].value = "a";
|
|
102
|
+
var myValue = myProp.getValue(["test.property"]);
|
|
103
|
+
expect(myValue).to.equal("a");
|
|
104
|
+
});
|
|
105
|
+
it("should work with an array of paths", function () {
|
|
106
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
107
|
+
myProp.get(["test[property]", ".property.", "test"]).setValue("b");
|
|
108
|
+
expect(myProp.getValue(["test[property]", ".property.", "test"])).to.equal("b");
|
|
109
|
+
});
|
|
110
|
+
it("should throw if using .getValue on a non-primitive property", function () {
|
|
111
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
104
112
|
var incorrectFn = function () {
|
|
105
|
-
myProp.getValue([
|
|
113
|
+
myProp.getValue(["test[property]"]);
|
|
106
114
|
};
|
|
107
115
|
expect(incorrectFn).to.throw();
|
|
108
116
|
});
|
|
109
117
|
});
|
|
110
|
-
describe(
|
|
111
|
-
it(
|
|
112
|
-
var myProp = PropertyFactory.create(
|
|
118
|
+
describe("GetValues should work", function () {
|
|
119
|
+
it("should return the values of a property", function () {
|
|
120
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
113
121
|
myProp.setValues({
|
|
114
|
-
|
|
115
|
-
'test"property"':
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
"simple_property": "string1",
|
|
123
|
+
'test"property"': "string3",
|
|
124
|
+
"test[property]": {
|
|
125
|
+
".property.": {
|
|
126
|
+
test: "string4",
|
|
119
127
|
},
|
|
120
128
|
},
|
|
121
129
|
});
|
|
122
130
|
expect(myProp.getValues()).to.deep.equal({
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
'test"property"':
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
"simple_property": "string1",
|
|
132
|
+
"test.property": "",
|
|
133
|
+
'test"property"': "string3",
|
|
134
|
+
"test[property]": {
|
|
135
|
+
".property.": {
|
|
136
|
+
test: "string4",
|
|
129
137
|
},
|
|
130
138
|
},
|
|
131
139
|
});
|
|
132
140
|
});
|
|
133
|
-
it(
|
|
134
|
-
var myProp = PropertyFactory.create(
|
|
141
|
+
it("setValues should accept the output of getValues as a valid input", function () {
|
|
142
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
135
143
|
myProp.setValues({
|
|
136
|
-
|
|
137
|
-
'test"property"':
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
"simple_property": "string1",
|
|
145
|
+
'test"property"': "string3",
|
|
146
|
+
"test[property]": {
|
|
147
|
+
".property.": {
|
|
148
|
+
test: "string4",
|
|
141
149
|
},
|
|
142
150
|
},
|
|
143
151
|
});
|
|
@@ -147,107 +155,104 @@ describe('BaseProperty', function () {
|
|
|
147
155
|
expect(correctFn).to.not.throw();
|
|
148
156
|
});
|
|
149
157
|
});
|
|
150
|
-
describe(
|
|
151
|
-
it(
|
|
152
|
-
var myProp = PropertyFactory.create(
|
|
158
|
+
describe("setValues should work", function () {
|
|
159
|
+
it("should accept an object and set each values in that object", function () {
|
|
160
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
153
161
|
myProp.setValues({
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
"simple_property": "string1",
|
|
163
|
+
"test[property]": {
|
|
164
|
+
".property.": {
|
|
165
|
+
test: "string2",
|
|
158
166
|
},
|
|
159
167
|
},
|
|
160
168
|
});
|
|
161
|
-
expect(myProp.get(
|
|
162
|
-
expect(myProp.get([
|
|
169
|
+
expect(myProp.get("simple_property").getValue()).to.equal("string1");
|
|
170
|
+
expect(myProp.get(["test[property]", ".property.", "test"]).getValue()).to.equal("string2");
|
|
163
171
|
});
|
|
164
|
-
it(
|
|
165
|
-
var myProp = PropertyFactory.create(
|
|
172
|
+
it("should throw if trying to insert in a non-exiting path", function () {
|
|
173
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
166
174
|
var invalidFunction = function () {
|
|
167
175
|
myProp.setValues({
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
176
|
+
"simple_property": "string1",
|
|
177
|
+
"test[property]": {
|
|
178
|
+
".property.": {
|
|
179
|
+
test123: "string2",
|
|
172
180
|
},
|
|
173
181
|
},
|
|
174
182
|
});
|
|
175
183
|
};
|
|
176
184
|
// TODO: move this to constants.js
|
|
177
|
-
expect(invalidFunction).to.throw(MSG.SET_VALUES_PATH_INVALID +
|
|
185
|
+
expect(invalidFunction).to.throw(MSG.SET_VALUES_PATH_INVALID + "test123");
|
|
178
186
|
});
|
|
179
|
-
it(
|
|
180
|
-
var myProp = PropertyFactory.create(
|
|
187
|
+
it("should throw if trying to insert into a path that resolves to a property", function () {
|
|
188
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
181
189
|
var invalidFunction = function () {
|
|
182
190
|
myProp.setValues({
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
191
|
+
"simple_property": "string1",
|
|
192
|
+
"test[property]": {
|
|
193
|
+
".property.": "string2",
|
|
186
194
|
},
|
|
187
195
|
});
|
|
188
196
|
};
|
|
189
|
-
expect(invalidFunction).to.throw(MSG.SET_VALUES_PATH_PROPERTY +
|
|
197
|
+
expect(invalidFunction).to.throw(MSG.SET_VALUES_PATH_PROPERTY + ".property.");
|
|
190
198
|
});
|
|
191
199
|
});
|
|
192
|
-
describe(
|
|
200
|
+
describe("Path resolution should work", function () {
|
|
193
201
|
// Test whether the right paths are returned
|
|
194
|
-
it(
|
|
195
|
-
var myProp = PropertyFactory.create(
|
|
196
|
-
expect(myProp.get(
|
|
197
|
-
expect(myProp.get(
|
|
202
|
+
it("should work with getAbsolutePath", function () {
|
|
203
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
204
|
+
expect(myProp.get("simple_property").getAbsolutePath()).to.equal("/simple_property");
|
|
205
|
+
expect(myProp.get("test.property").getAbsolutePath()).to.equal('/"test.property"');
|
|
198
206
|
expect(myProp.get('test"property"').getAbsolutePath()).to.equal('/"test\\"property\\""');
|
|
199
|
-
expect(myProp.get(
|
|
200
|
-
expect(myProp.get('test[property]')
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
expect(myProp.get(['test[property]', '.property.', 'test']).getRelativePath(myProp.get('simple_property')))
|
|
212
|
-
.to.equal('../"test[property]".".property.".test');
|
|
213
|
-
expect(nested.getRelativePath(myProp.get(['test[property]', '.property.', 'test']))).to.equal('../../');
|
|
207
|
+
expect(myProp.get("test[property]").getAbsolutePath()).to.equal('/"test[property]"');
|
|
208
|
+
expect(myProp.get("test[property]").get(".property.").getAbsolutePath()).to.equal('/"test[property]".".property."');
|
|
209
|
+
expect(myProp.get("test[property]").get(".property.").get("test").getAbsolutePath()).to.equal('/"test[property]".".property.".test');
|
|
210
|
+
});
|
|
211
|
+
it("should work with getRelativePath", function () {
|
|
212
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
213
|
+
var nested = myProp.get("test[property]");
|
|
214
|
+
expect(myProp.get(["test[property]", ".property.", "test"]).getRelativePath(nested)).to.equal('".property.".test');
|
|
215
|
+
expect(myProp
|
|
216
|
+
.get(["test[property]", ".property.", "test"])
|
|
217
|
+
.getRelativePath(myProp.get("simple_property"))).to.equal('../"test[property]".".property.".test');
|
|
218
|
+
expect(nested.getRelativePath(myProp.get(["test[property]", ".property.", "test"]))).to.equal("../../");
|
|
214
219
|
});
|
|
215
220
|
// Test that path resolution works
|
|
216
|
-
it(
|
|
217
|
-
var myProp = PropertyFactory.create(
|
|
218
|
-
expect(myProp.resolvePath(
|
|
219
|
-
expect(myProp.resolvePath('"test.property"')).to.equal(myProp.get(
|
|
221
|
+
it("should work with resolvePath", function () {
|
|
222
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
223
|
+
expect(myProp.resolvePath("simple_property")).to.equal(myProp.get("simple_property"));
|
|
224
|
+
expect(myProp.resolvePath('"test.property"')).to.equal(myProp.get("test.property"));
|
|
220
225
|
expect(myProp.resolvePath('"test\\"property\\""')).to.equal(myProp.get('test"property"'));
|
|
221
|
-
expect(myProp.resolvePath('"test[property]"')).to.equal(myProp.get(
|
|
222
|
-
expect(myProp.resolvePath('"test[property]".".property."')).to.equal(myProp.get(
|
|
223
|
-
expect(myProp.resolvePath('"test[property]".".property.".test')).to.equal(myProp.get(
|
|
224
|
-
expect(myProp.resolvePath(
|
|
225
|
-
expect(myProp.resolvePath(
|
|
226
|
-
expect(myProp.get(
|
|
227
|
-
expect(myProp.get(
|
|
228
|
-
});
|
|
229
|
-
it(
|
|
230
|
-
var myProp = PropertyFactory.create(
|
|
231
|
-
expect(myProp.resolvePath(
|
|
232
|
-
expect(myProp.resolvePath(
|
|
226
|
+
expect(myProp.resolvePath('"test[property]"')).to.equal(myProp.get("test[property]"));
|
|
227
|
+
expect(myProp.resolvePath('"test[property]".".property."')).to.equal(myProp.get("test[property]").get(".property."));
|
|
228
|
+
expect(myProp.resolvePath('"test[property]".".property.".test')).to.equal(myProp.get("test[property]").get(".property.").get("test"));
|
|
229
|
+
expect(myProp.resolvePath("/")).to.equal(myProp);
|
|
230
|
+
expect(myProp.resolvePath("/simple_property")).to.equal(myProp.get("simple_property"));
|
|
231
|
+
expect(myProp.get("simple_property").resolvePath("/")).to.equal(myProp);
|
|
232
|
+
expect(myProp.get("simple_property").resolvePath("/simple_property")).to.equal(myProp.get("simple_property"));
|
|
233
|
+
});
|
|
234
|
+
it("should return undefined for invalid paths", function () {
|
|
235
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
236
|
+
expect(myProp.resolvePath("invalid_path")).to.be.undefined;
|
|
237
|
+
expect(myProp.resolvePath("invalid_path.invalid_child")).to.be.undefined;
|
|
233
238
|
});
|
|
234
239
|
});
|
|
235
|
-
describe(
|
|
236
|
-
it(
|
|
237
|
-
var property = PropertyFactory.create(
|
|
238
|
-
property.resolvePath('"test[property]".".property.".test').value =
|
|
240
|
+
describe("cleanDirty", function () {
|
|
241
|
+
it("should work for paths with special characters", function () {
|
|
242
|
+
var property = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
243
|
+
property.resolvePath('"test[property]".".property.".test').value = "test";
|
|
239
244
|
property.cleanDirty();
|
|
240
245
|
expect(property._serialize(true)).to.be.empty;
|
|
241
246
|
expect(property.getPendingChanges()).to.deep.equal(new ChangeSet({}));
|
|
242
247
|
});
|
|
243
248
|
});
|
|
244
|
-
it(
|
|
245
|
-
var nodeProperty = PropertyFactory.create(
|
|
249
|
+
it("should clone the property set", function (done) {
|
|
250
|
+
var nodeProperty = PropertyFactory.create("NodeProperty");
|
|
246
251
|
nodeProperty.deserialize({
|
|
247
252
|
insert: {
|
|
248
253
|
String: {
|
|
249
|
-
result1:
|
|
250
|
-
result2:
|
|
254
|
+
result1: "foo",
|
|
255
|
+
result2: "bar",
|
|
251
256
|
},
|
|
252
257
|
NodeProperty: {
|
|
253
258
|
result3: {
|
|
@@ -264,16 +269,16 @@ describe('BaseProperty', function () {
|
|
|
264
269
|
expect(nodeProperty._serialize(false)).to.eql(clone._serialize(false));
|
|
265
270
|
done();
|
|
266
271
|
});
|
|
267
|
-
it(
|
|
268
|
-
let nodeProperty = PropertyFactory.create(
|
|
269
|
-
nodeProperty.insert(
|
|
270
|
-
nodeProperty.insert(
|
|
271
|
-
nodeProperty.insert(
|
|
272
|
-
nodeProperty.insert(
|
|
272
|
+
it("should support reapplying dirty flags on non-identical changeSets", function (done) {
|
|
273
|
+
let nodeProperty = PropertyFactory.create("NodeProperty");
|
|
274
|
+
nodeProperty.insert("result1", PropertyFactory.create("String"));
|
|
275
|
+
nodeProperty.insert("result2", PropertyFactory.create("String"));
|
|
276
|
+
nodeProperty.insert("result3", PropertyFactory.create("Int32"));
|
|
277
|
+
nodeProperty.insert("result4", PropertyFactory.create("Int32"));
|
|
273
278
|
const changeset1 = {
|
|
274
279
|
String: {
|
|
275
|
-
result1:
|
|
276
|
-
result2:
|
|
280
|
+
result1: "foo",
|
|
281
|
+
result2: "bar",
|
|
277
282
|
},
|
|
278
283
|
};
|
|
279
284
|
const changeset2 = {
|
|
@@ -285,110 +290,115 @@ describe('BaseProperty', function () {
|
|
|
285
290
|
nodeProperty._reapplyDirtyFlags(changeset1, changeset2);
|
|
286
291
|
done();
|
|
287
292
|
});
|
|
288
|
-
it(
|
|
293
|
+
it("should be able to handle duplicate namespace", function () {
|
|
289
294
|
var ANumber = {
|
|
290
|
-
typeid:
|
|
291
|
-
properties: [
|
|
292
|
-
|
|
293
|
-
|
|
295
|
+
typeid: "autodesk.tests:ANumber-1.0.0",
|
|
296
|
+
properties: [
|
|
297
|
+
{
|
|
298
|
+
id: "aValue",
|
|
299
|
+
typeid: "Int32",
|
|
300
|
+
},
|
|
301
|
+
],
|
|
294
302
|
};
|
|
295
303
|
PropertyFactory.register(ANumber);
|
|
296
304
|
var SomeNumbers = {
|
|
297
|
-
typeid:
|
|
305
|
+
typeid: "autodesk.tests:SomeNumbers-1.0.0",
|
|
298
306
|
properties: [
|
|
299
|
-
{ id:
|
|
300
|
-
{ id:
|
|
301
|
-
{ id:
|
|
307
|
+
{ id: "aValue", typeid: "autodesk.tests:ANumber-1.0.0" },
|
|
308
|
+
{ id: "anotherValue", typeid: "autodesk.tests:ANumber-1.0.0" },
|
|
309
|
+
{ id: "thirdValue", typeid: "autodesk.tests:ANumber-1.0.0" },
|
|
302
310
|
],
|
|
303
311
|
};
|
|
304
312
|
PropertyFactory.register(SomeNumbers);
|
|
305
313
|
var originalSomeNumbers = PropertyFactory.create(SomeNumbers.typeid);
|
|
306
|
-
let root = PropertyFactory.create(
|
|
307
|
-
root.insert(
|
|
308
|
-
var someNumbers = root.resolvePath(
|
|
314
|
+
let root = PropertyFactory.create("NodeProperty");
|
|
315
|
+
root.insert("aValue", originalSomeNumbers);
|
|
316
|
+
var someNumbers = root.resolvePath("aValue");
|
|
309
317
|
expect(someNumbers).to.equal(originalSomeNumbers);
|
|
310
|
-
var aNumber = root.resolvePath(
|
|
318
|
+
var aNumber = root.resolvePath("aValue.aValue");
|
|
311
319
|
expect(aNumber).to.exist;
|
|
312
|
-
var aValue = root.resolvePath(
|
|
320
|
+
var aValue = root.resolvePath("aValue.aValue.aValue");
|
|
313
321
|
expect(aValue).to.exist;
|
|
314
322
|
});
|
|
315
|
-
describe(
|
|
316
|
-
it(
|
|
317
|
-
var myProp = PropertyFactory.create(
|
|
318
|
-
expect(myProp.getContext()).to.equal(
|
|
323
|
+
describe("getContext", function () {
|
|
324
|
+
it("should work with context of single", function () {
|
|
325
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
326
|
+
expect(myProp.getContext()).to.equal("single");
|
|
319
327
|
});
|
|
320
|
-
it(
|
|
321
|
-
var arrayProp = PropertyFactory.create(
|
|
322
|
-
expect(arrayProp.getContext()).to.equal(
|
|
323
|
-
var mapProp = PropertyFactory.create(
|
|
324
|
-
expect(mapProp.getContext()).to.equal(
|
|
328
|
+
it("should work with other contexts", function () {
|
|
329
|
+
var arrayProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0", "array");
|
|
330
|
+
expect(arrayProp.getContext()).to.equal("array");
|
|
331
|
+
var mapProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0", "map");
|
|
332
|
+
expect(mapProp.getContext()).to.equal("map");
|
|
325
333
|
});
|
|
326
334
|
});
|
|
327
|
-
describe(
|
|
328
|
-
it(
|
|
329
|
-
var myProp = PropertyFactory.create(
|
|
330
|
-
expect(myProp.getFullTypeid()).to.equal(
|
|
335
|
+
describe("getFullTypeid", function () {
|
|
336
|
+
it("should return the typeid of the property", function () {
|
|
337
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
338
|
+
expect(myProp.getFullTypeid()).to.equal("autodesk.tests:property.with.special.characters-1.0.0");
|
|
331
339
|
});
|
|
332
340
|
});
|
|
333
|
-
describe(
|
|
334
|
-
it(
|
|
335
|
-
var myProp = PropertyFactory.create(
|
|
336
|
-
expect(myProp.getTypeid()).to.equal(
|
|
341
|
+
describe("getTypeid", function () {
|
|
342
|
+
it("should return the typeid of the property", function () {
|
|
343
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
344
|
+
expect(myProp.getTypeid()).to.equal("autodesk.tests:property.with.special.characters-1.0.0");
|
|
337
345
|
});
|
|
338
346
|
});
|
|
339
|
-
describe(
|
|
340
|
-
it(
|
|
341
|
-
var myProp = PropertyFactory.create(
|
|
342
|
-
var nested = myProp.get(
|
|
343
|
-
expect(nested.getId()).to.equal(
|
|
347
|
+
describe("getId", function () {
|
|
348
|
+
it("should return the id of the property", function () {
|
|
349
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
350
|
+
var nested = myProp.get("test.property");
|
|
351
|
+
expect(nested.getId()).to.equal("test.property");
|
|
344
352
|
});
|
|
345
353
|
});
|
|
346
|
-
describe(
|
|
347
|
-
it(
|
|
348
|
-
var myProp = PropertyFactory.create(
|
|
349
|
-
var nested = myProp.get(
|
|
354
|
+
describe("getParent", function () {
|
|
355
|
+
it("should return the parent property", function () {
|
|
356
|
+
var myProp = PropertyFactory.create("autodesk.tests:property.with.special.characters-1.0.0");
|
|
357
|
+
var nested = myProp.get("test.property");
|
|
350
358
|
expect(nested.getParent()).to.deep.equal(myProp);
|
|
351
359
|
});
|
|
352
360
|
});
|
|
353
361
|
// Other aspects of traverseDown function are already tested. Missing BREAK_TRAVERSAL and paths only.
|
|
354
|
-
describe(
|
|
362
|
+
describe("traverseDown, hasPendingChanges and getPendingChanges", function () {
|
|
355
363
|
var BREAK_TRAVERSAL;
|
|
356
364
|
before(function () {
|
|
357
|
-
BREAK_TRAVERSAL = require(
|
|
365
|
+
BREAK_TRAVERSAL = require("../..").BaseProperty.BREAK_TRAVERSAL;
|
|
358
366
|
var TestTraversalObject = {
|
|
359
|
-
typeid:
|
|
367
|
+
typeid: "autodesk.tests:property.traversal-1.0.0",
|
|
360
368
|
properties: [
|
|
361
|
-
{ id:
|
|
369
|
+
{ id: "p1", typeid: "String" },
|
|
362
370
|
{
|
|
363
|
-
id:
|
|
371
|
+
id: "p2",
|
|
372
|
+
properties: [
|
|
364
373
|
{
|
|
365
|
-
id:
|
|
366
|
-
|
|
367
|
-
{ id:
|
|
368
|
-
{ id:
|
|
374
|
+
id: "p2p1",
|
|
375
|
+
properties: [
|
|
376
|
+
{ id: "p2p1p1", typeid: "String" },
|
|
377
|
+
{ id: "p2p1p2", typeid: "String" },
|
|
378
|
+
{ id: "p2p1p3", typeid: "String" },
|
|
369
379
|
],
|
|
370
380
|
},
|
|
371
381
|
{
|
|
372
|
-
id:
|
|
373
|
-
|
|
374
|
-
{ id:
|
|
375
|
-
{ id:
|
|
382
|
+
id: "p2p2",
|
|
383
|
+
properties: [
|
|
384
|
+
{ id: "p2p2p1", typeid: "String" },
|
|
385
|
+
{ id: "p2p2p2", typeid: "String" },
|
|
386
|
+
{ id: "p2p2p3", typeid: "Int32" },
|
|
376
387
|
],
|
|
377
388
|
},
|
|
378
389
|
],
|
|
379
390
|
},
|
|
380
|
-
{ id:
|
|
391
|
+
{ id: "p3", typeid: "String" },
|
|
381
392
|
{
|
|
382
|
-
id:
|
|
393
|
+
id: "p4",
|
|
394
|
+
properties: [
|
|
383
395
|
{
|
|
384
|
-
id:
|
|
385
|
-
|
|
386
|
-
],
|
|
396
|
+
id: "p4p1",
|
|
397
|
+
properties: [{ id: "p4p1p1", typeid: "String" }],
|
|
387
398
|
},
|
|
388
399
|
{
|
|
389
|
-
id:
|
|
390
|
-
|
|
391
|
-
],
|
|
400
|
+
id: "p4p2",
|
|
401
|
+
properties: [{ id: "p4p2p1", typeid: "String" }],
|
|
392
402
|
},
|
|
393
403
|
],
|
|
394
404
|
},
|
|
@@ -396,8 +406,8 @@ describe('BaseProperty', function () {
|
|
|
396
406
|
};
|
|
397
407
|
PropertyFactory.register(TestTraversalObject);
|
|
398
408
|
});
|
|
399
|
-
it(
|
|
400
|
-
var property = PropertyFactory.create(
|
|
409
|
+
it("should stop when callback returns BREAK_TRAVERSAL", function () {
|
|
410
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
401
411
|
var nbrCalls = 0;
|
|
402
412
|
var breakTrav = function (prop) {
|
|
403
413
|
if (++nbrCalls === 5) {
|
|
@@ -408,113 +418,116 @@ describe('BaseProperty', function () {
|
|
|
408
418
|
property.traverseDown(breakTrav);
|
|
409
419
|
expect(nbrCalls).to.equal(5);
|
|
410
420
|
});
|
|
411
|
-
it(
|
|
421
|
+
it("should provide path of each prop", function () {
|
|
412
422
|
var arrPaths = [];
|
|
413
423
|
var gatherPaths = function (prop, path) {
|
|
414
424
|
arrPaths.push(path);
|
|
415
425
|
};
|
|
416
|
-
var property = PropertyFactory.create(
|
|
417
|
-
property.resolvePath(
|
|
418
|
-
expect(arrPaths).to.deep.equal([
|
|
419
|
-
});
|
|
420
|
-
it(
|
|
421
|
-
var property = PropertyFactory.create(
|
|
422
|
-
expect(property.resolvePath(
|
|
423
|
-
expect(property.resolvePath(
|
|
424
|
-
property.resolvePath(
|
|
425
|
-
property.resolvePath(
|
|
426
|
-
property.resolvePath(
|
|
427
|
-
expect(property.resolvePath(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
426
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
427
|
+
property.resolvePath("p4").traverseDown(gatherPaths);
|
|
428
|
+
expect(arrPaths).to.deep.equal(["p4p1", "p4p1.p4p1p1", "p4p2", "p4p2.p4p2p1"]);
|
|
429
|
+
});
|
|
430
|
+
it("should return pending changes", function () {
|
|
431
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
432
|
+
expect(property.resolvePath("p2").getPendingChanges()).to.deep.equal(new ChangeSet({}));
|
|
433
|
+
expect(property.resolvePath("p2").hasPendingChanges()).to.be.false;
|
|
434
|
+
property.resolvePath("p2.p2p1.p2p1p2").value = "Hi";
|
|
435
|
+
property.resolvePath("p2.p2p2.p2p2p1").value = "Hello";
|
|
436
|
+
property.resolvePath("p2.p2p2.p2p2p3").value = 42;
|
|
437
|
+
expect(property.resolvePath("p2").getPendingChanges()).to.deep.equal(new ChangeSet({
|
|
438
|
+
Int32: { "p2p2.p2p2p3": 42 },
|
|
439
|
+
String: { "p2p1.p2p1p2": "Hi", "p2p2.p2p2p1": "Hello" },
|
|
440
|
+
}));
|
|
441
|
+
expect(property.resolvePath("p2").hasPendingChanges()).to.be.true;
|
|
442
|
+
});
|
|
443
|
+
it("should output a pretty string with prettyPrint()", function () {
|
|
444
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
445
|
+
var expectedPrettyStr = "p2 (ContainerProperty):\n" +
|
|
446
|
+
" p2p1 (ContainerProperty):\n" +
|
|
434
447
|
' p2p1p1 (String): ""\n' +
|
|
435
448
|
' p2p1p2 (String): ""\n' +
|
|
436
449
|
' p2p1p3 (String): ""\n' +
|
|
437
|
-
|
|
450
|
+
" p2p2 (ContainerProperty):\n" +
|
|
438
451
|
' p2p2p1 (String): ""\n' +
|
|
439
452
|
' p2p2p2 (String): ""\n' +
|
|
440
|
-
|
|
441
|
-
var prettyStr =
|
|
442
|
-
property.resolvePath(
|
|
443
|
-
prettyStr += str +
|
|
453
|
+
" p2p2p3 (Int32): 0\n";
|
|
454
|
+
var prettyStr = "";
|
|
455
|
+
property.resolvePath("p2").prettyPrint(function (str) {
|
|
456
|
+
prettyStr += str + "\n";
|
|
444
457
|
});
|
|
445
458
|
expect(prettyStr).to.equal(expectedPrettyStr);
|
|
446
459
|
});
|
|
447
460
|
});
|
|
448
|
-
describe(
|
|
461
|
+
describe("Ancestry relations should be resolved correctly", function () {
|
|
449
462
|
/**
|
|
450
463
|
* creates a workspace
|
|
451
464
|
* @return {property-properties.Workspace} workspace
|
|
452
465
|
*/
|
|
453
466
|
function createRootProperty() {
|
|
454
|
-
return Promise.resolve(PropertyFactory.create(
|
|
467
|
+
return Promise.resolve(PropertyFactory.create("NodeProperty"));
|
|
455
468
|
}
|
|
456
|
-
it(
|
|
469
|
+
it("property should be ancestor of subproperty", function () {
|
|
457
470
|
return createRootProperty().then(function (workspace) {
|
|
458
|
-
var property = PropertyFactory.create(
|
|
459
|
-
var subproperty = property.resolvePath(
|
|
460
|
-
workspace.insert(
|
|
471
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
472
|
+
var subproperty = property.resolvePath("p2.p2p1.p2p1p2");
|
|
473
|
+
workspace.insert("test", property);
|
|
461
474
|
expect(property.isAncestorOf(subproperty)).to.equal(true);
|
|
462
475
|
});
|
|
463
476
|
});
|
|
464
|
-
it(
|
|
477
|
+
it("property should not be ancestor itself", function () {
|
|
465
478
|
return createRootProperty().then(function (workspace) {
|
|
466
|
-
var property = PropertyFactory.create(
|
|
479
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
467
480
|
expect(property.isAncestorOf(property)).to.equal(false);
|
|
468
481
|
});
|
|
469
482
|
});
|
|
470
|
-
it(
|
|
471
|
-
var property = PropertyFactory.create(
|
|
472
|
-
var subproperty = property.resolvePath(
|
|
483
|
+
it("property not in workspace should correctly resolve ancestry", function () {
|
|
484
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
485
|
+
var subproperty = property.resolvePath("p2.p2p1.p2p1p2");
|
|
473
486
|
expect(property.isAncestorOf(subproperty)).to.equal(true);
|
|
474
487
|
expect(subproperty.isDescendantOf(property)).to.equal(true);
|
|
475
488
|
});
|
|
476
|
-
it(
|
|
489
|
+
it("property should be ancestor of subproperty", function () {
|
|
477
490
|
return createRootProperty().then(function (workspace) {
|
|
478
|
-
var property = PropertyFactory.create(
|
|
479
|
-
var subproperty = property.resolvePath(
|
|
480
|
-
workspace.insert(
|
|
491
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
492
|
+
var subproperty = property.resolvePath("p2.p2p1.p2p1p2");
|
|
493
|
+
workspace.insert("test", property);
|
|
481
494
|
expect(property.isAncestorOf(subproperty)).to.equal(true);
|
|
482
495
|
});
|
|
483
496
|
});
|
|
484
|
-
it(
|
|
497
|
+
it("subproperty should be descendant of property", function () {
|
|
485
498
|
return createRootProperty().then(function (workspace) {
|
|
486
|
-
var property = PropertyFactory.create(
|
|
487
|
-
var subproperty = property.resolvePath(
|
|
488
|
-
workspace.insert(
|
|
499
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
500
|
+
var subproperty = property.resolvePath("p2.p2p1.p2p1p2");
|
|
501
|
+
workspace.insert("test", property);
|
|
489
502
|
expect(subproperty.isDescendantOf(property)).to.equal(true);
|
|
490
503
|
});
|
|
491
504
|
});
|
|
492
|
-
it(
|
|
505
|
+
it("property in array property should be descendant of array", function () {
|
|
493
506
|
return createRootProperty().then(function (workspace) {
|
|
494
|
-
var property = PropertyFactory.create(
|
|
495
|
-
var element = PropertyFactory.create(
|
|
507
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0", "array");
|
|
508
|
+
var element = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
496
509
|
property.push(element);
|
|
497
|
-
var subproperty = element.resolvePath(
|
|
498
|
-
workspace.insert(
|
|
510
|
+
var subproperty = element.resolvePath("p2.p2p1.p2p1p2");
|
|
511
|
+
workspace.insert("test", property);
|
|
499
512
|
expect(subproperty.isDescendantOf(property)).to.equal(true);
|
|
500
513
|
});
|
|
501
514
|
});
|
|
502
|
-
it(
|
|
515
|
+
it("array property should be ancestor of property in array", function () {
|
|
503
516
|
return createRootProperty().then(function (workspace) {
|
|
504
|
-
var property = PropertyFactory.create(
|
|
505
|
-
var element = PropertyFactory.create(
|
|
517
|
+
var property = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0", "array");
|
|
518
|
+
var element = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
506
519
|
property.push(element);
|
|
507
|
-
var subproperty = element.resolvePath(
|
|
508
|
-
workspace.insert(
|
|
520
|
+
var subproperty = element.resolvePath("p2.p2p1.p2p1p2");
|
|
521
|
+
workspace.insert("test", property);
|
|
509
522
|
expect(property.isAncestorOf(subproperty)).to.equal(true);
|
|
510
523
|
});
|
|
511
524
|
});
|
|
512
|
-
it(
|
|
525
|
+
it("two different properties should not be related", function () {
|
|
513
526
|
return createRootProperty().then(function (workspace) {
|
|
514
|
-
var prop1 = PropertyFactory.create(
|
|
515
|
-
var prop2 = PropertyFactory.create(
|
|
516
|
-
workspace.insert(
|
|
517
|
-
workspace.insert(
|
|
527
|
+
var prop1 = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
528
|
+
var prop2 = PropertyFactory.create("autodesk.tests:property.traversal-1.0.0");
|
|
529
|
+
workspace.insert("test1", prop1);
|
|
530
|
+
workspace.insert("test2", prop2);
|
|
518
531
|
expect(prop2.isAncestorOf(prop1)).to.equal(false);
|
|
519
532
|
expect(prop2.isDescendantOf(prop1)).to.equal(false);
|
|
520
533
|
expect(prop1.isAncestorOf(prop2)).to.equal(false);
|