@fluid-experimental/property-changeset 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1
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/changeset.d.ts +2 -2
- package/dist/changeset.d.ts.map +1 -1
- package/dist/changeset.js +61 -45
- package/dist/changeset.js.map +1 -1
- package/dist/changeset_operations/array.d.ts +6 -6
- package/dist/changeset_operations/array.d.ts.map +1 -1
- package/dist/changeset_operations/array.js +87 -56
- package/dist/changeset_operations/array.js.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.js +43 -41
- package/dist/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
- package/dist/changeset_operations/indexedCollection.js +76 -44
- package/dist/changeset_operations/indexedCollection.js.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.d.ts.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.js +2 -1
- package/dist/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/dist/changeset_operations/operationTypes.d.ts.map +1 -1
- package/dist/changeset_operations/operationTypes.js.map +1 -1
- package/dist/helpers/typeidHelper.d.ts +10 -10
- package/dist/helpers/typeidHelper.d.ts.map +1 -1
- package/dist/helpers/typeidHelper.js +19 -17
- package/dist/helpers/typeidHelper.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/isReservedKeyword.d.ts.map +1 -1
- package/dist/isReservedKeyword.js.map +1 -1
- package/dist/pathHelper.d.ts.map +1 -1
- package/dist/pathHelper.js +16 -10
- package/dist/pathHelper.js.map +1 -1
- package/dist/rebase.d.ts.map +1 -1
- package/dist/rebase.js +20 -13
- package/dist/rebase.js.map +1 -1
- package/dist/templateSchema.d.ts.map +1 -1
- package/dist/templateSchema.js +10 -11
- package/dist/templateSchema.js.map +1 -1
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/templateValidator.js +135 -102
- package/dist/templateValidator.js.map +1 -1
- package/dist/test/array.spec.js +141 -343
- package/dist/test/array.spec.js.map +1 -1
- package/dist/test/pathHelper.spec.js +299 -166
- package/dist/test/pathHelper.spec.js.map +1 -1
- package/dist/test/reversibleCs.spec.js.map +1 -1
- package/dist/test/schemaValidator.js +3 -1
- package/dist/test/schemaValidator.js.map +1 -1
- package/dist/test/schemas/badBothPropertiesAndTypeid.js +8 -8
- package/dist/test/schemas/badBothPropertiesAndTypeid.js.map +1 -1
- package/dist/test/schemas/badInvalidSemverInTypeid.js +18 -16
- package/dist/test/schemas/badInvalidSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badMissingSemverInTypeid.js +18 -16
- package/dist/test/schemas/badMissingSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badNestedProperties.js +18 -17
- package/dist/test/schemas/badNestedProperties.js.map +1 -1
- package/dist/test/schemas/badPrimitiveTypeid.js +9 -8
- package/dist/test/schemas/badPrimitiveTypeid.js.map +1 -1
- package/dist/test/schemas/badVersionedTypeid.js +19 -17
- package/dist/test/schemas/badVersionedTypeid.js.map +1 -1
- package/dist/test/schemas/goodColorPalette.js +4 -4
- package/dist/test/schemas/goodColorPalette.js.map +1 -1
- package/dist/test/schemas/goodDraftAsVersion.js +2 -4
- package/dist/test/schemas/goodDraftAsVersion.js.map +1 -1
- package/dist/test/schemas/goodPointId.js +18 -16
- package/dist/test/schemas/goodPointId.js.map +1 -1
- package/dist/test/schemas/goodReferenceAndRegular.js +5 -5
- package/dist/test/schemas/goodReferenceAndRegular.js.map +1 -1
- package/dist/test/schemas/goodReservedTypes.js +8 -7
- package/dist/test/schemas/goodReservedTypes.js.map +1 -1
- package/dist/test/schemas/goodUIBorder.js +19 -16
- package/dist/test/schemas/goodUIBorder.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/dist/test/validator/templateSyntax.spec.js.map +1 -1
- package/dist/test/validator/templateValidator.spec.js +329 -306
- package/dist/test/validator/templateValidator.spec.js.map +1 -1
- package/dist/test/validator/typeidHelper.spec.js +98 -65
- package/dist/test/validator/typeidHelper.spec.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +149 -95
- package/dist/utils.js.map +1 -1
- package/dist/validationResultBuilder.d.ts.map +1 -1
- package/dist/validationResultBuilder.js.map +1 -1
- package/lib/changeset.js +63 -47
- package/lib/changeset.js.map +1 -1
- package/lib/changeset_operations/array.js +88 -57
- package/lib/changeset_operations/array.js.map +1 -1
- package/lib/changeset_operations/arrayChangesetIterator.js +43 -41
- package/lib/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/lib/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/lib/changeset_operations/indexedCollection.js +76 -44
- package/lib/changeset_operations/indexedCollection.js.map +1 -1
- package/lib/changeset_operations/isEmptyChangeset.js +2 -1
- package/lib/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/lib/changeset_operations/operationTypes.js.map +1 -1
- package/lib/helpers/typeidHelper.js +19 -17
- package/lib/helpers/typeidHelper.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/isReservedKeyword.js.map +1 -1
- package/lib/pathHelper.js +17 -11
- package/lib/pathHelper.js.map +1 -1
- package/lib/rebase.js +20 -13
- package/lib/rebase.js.map +1 -1
- package/lib/templateSchema.js +10 -11
- package/lib/templateSchema.js.map +1 -1
- package/lib/templateValidator.js +135 -102
- package/lib/templateValidator.js.map +1 -1
- package/lib/utils.js +149 -95
- package/lib/utils.js.map +1 -1
- package/lib/validationResultBuilder.js.map +1 -1
- package/package.json +100 -100
|
@@ -12,16 +12,19 @@ const chai_1 = require("chai");
|
|
|
12
12
|
const schemaValidator_1 = require("../schemaValidator");
|
|
13
13
|
const templateValidator_1 = require("../../templateValidator");
|
|
14
14
|
(function () {
|
|
15
|
-
let MSG = require(
|
|
16
|
-
let semver = require(
|
|
15
|
+
let MSG = require("@fluid-experimental/property-common").constants.MSG;
|
|
16
|
+
let semver = require("semver");
|
|
17
17
|
const performValidation = function (async, template, templatePrevious, skipSemver, asyncErrorMessage) {
|
|
18
18
|
let schemaValidator = new schemaValidator_1.SchemaValidator();
|
|
19
19
|
return async
|
|
20
|
-
? schemaValidator
|
|
20
|
+
? schemaValidator
|
|
21
|
+
.validate(template, templatePrevious, async, skipSemver)
|
|
22
|
+
.catch((error) => {
|
|
21
23
|
(0, chai_1.expect)(error.message).to.have.string(asyncErrorMessage);
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
})
|
|
25
|
+
: new Promise((resolve) => {
|
|
26
|
+
resolve(schemaValidator.validate(template, templatePrevious, async, skipSemver));
|
|
27
|
+
});
|
|
25
28
|
};
|
|
26
29
|
// Performs both synchronous and asynchronous validation
|
|
27
30
|
let validate = function (expectations, template, templatePrevious, skipSemver, asyncErrorMessage) {
|
|
@@ -30,21 +33,21 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
30
33
|
.then(performValidation(true, template, templatePrevious, skipSemver, asyncErrorMessage))
|
|
31
34
|
.then(expectations);
|
|
32
35
|
};
|
|
33
|
-
describe(
|
|
36
|
+
describe("Template Validation", function () {
|
|
34
37
|
// --- INPUT ---
|
|
35
|
-
describe(
|
|
36
|
-
it(
|
|
38
|
+
describe("input validation", function () {
|
|
39
|
+
it("fail: empty template", function () {
|
|
37
40
|
let expectations = function (result) {
|
|
38
|
-
(0, chai_1.expect)(result).property(
|
|
41
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
39
42
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
40
43
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.NO_TEMPLATE);
|
|
41
44
|
return result;
|
|
42
45
|
};
|
|
43
46
|
return validate(expectations);
|
|
44
47
|
});
|
|
45
|
-
it(
|
|
48
|
+
it("fail: template with no typeid", function () {
|
|
46
49
|
let expectations = function (result) {
|
|
47
|
-
(0, chai_1.expect)(result).property(
|
|
50
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
48
51
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
49
52
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MISSING_TYPE_ID);
|
|
50
53
|
return result;
|
|
@@ -53,11 +56,11 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
53
56
|
});
|
|
54
57
|
});
|
|
55
58
|
// --- TYPEID ---
|
|
56
|
-
describe(
|
|
57
|
-
it(
|
|
58
|
-
let template = JSON.parse(JSON.stringify(require(
|
|
59
|
+
describe("typeid validation", function () {
|
|
60
|
+
it("pass: valid typeid", function () {
|
|
61
|
+
let template = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
59
62
|
let expectations = function (result) {
|
|
60
|
-
(0, chai_1.expect)(result).property(
|
|
63
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
61
64
|
(0, chai_1.expect)(result.typeid).to.equal(template.typeid);
|
|
62
65
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
63
66
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
@@ -65,34 +68,34 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
65
68
|
};
|
|
66
69
|
return validate(expectations, template);
|
|
67
70
|
});
|
|
68
|
-
it(
|
|
69
|
-
let template = JSON.parse(JSON.stringify(require(
|
|
71
|
+
it("fail: missing semver", function () {
|
|
72
|
+
let template = JSON.parse(JSON.stringify(require("../schemas/badMissingSemverInTypeid")));
|
|
70
73
|
let expectations = function (result) {
|
|
71
|
-
(0, chai_1.expect)(result).property(
|
|
74
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
72
75
|
(0, chai_1.expect)(result.typeid).to.equal(template.typeid);
|
|
73
76
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
74
|
-
(0, chai_1.expect)(result.errors[0].message).to.have.string('
|
|
75
|
-
(0, chai_1.expect)(result.errors[0].dataPath).to.equal(
|
|
77
|
+
(0, chai_1.expect)(result.errors[0].message).to.have.string("'TeamLeoValidation2:PointID' is not valid");
|
|
78
|
+
(0, chai_1.expect)(result.errors[0].dataPath).to.equal("/typeid");
|
|
76
79
|
return result;
|
|
77
80
|
};
|
|
78
81
|
return validate(expectations, template);
|
|
79
82
|
});
|
|
80
|
-
it(
|
|
81
|
-
let template = JSON.parse(JSON.stringify(require(
|
|
83
|
+
it("fail: invalid semver 1", function () {
|
|
84
|
+
let template = JSON.parse(JSON.stringify(require("../schemas/badInvalidSemverInTypeid")));
|
|
82
85
|
let expectations = function (result) {
|
|
83
|
-
(0, chai_1.expect)(result).property(
|
|
86
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
84
87
|
(0, chai_1.expect)(result.typeid).to.equal(template.typeid);
|
|
85
88
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
86
|
-
(0, chai_1.expect)(result.errors[0].dataPath).to.equal(
|
|
89
|
+
(0, chai_1.expect)(result.errors[0].dataPath).to.equal("/typeid");
|
|
87
90
|
return result;
|
|
88
91
|
};
|
|
89
92
|
return validate(expectations, template);
|
|
90
93
|
});
|
|
91
|
-
it(
|
|
92
|
-
let template = JSON.parse(JSON.stringify(require(
|
|
93
|
-
template.typeid =
|
|
94
|
+
it("fail: invalid semver 2", function () {
|
|
95
|
+
let template = JSON.parse(JSON.stringify(require("../schemas/badInvalidSemverInTypeid")));
|
|
96
|
+
template.typeid = "TeamLeoValidation2:PointID-1.0.01";
|
|
94
97
|
let expectations = function (result) {
|
|
95
|
-
(0, chai_1.expect)(result).property(
|
|
98
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
96
99
|
(0, chai_1.expect)(result.typeid).to.equal(template.typeid);
|
|
97
100
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
98
101
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.INVALID_VERSION_1);
|
|
@@ -100,41 +103,41 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
100
103
|
};
|
|
101
104
|
return validate(expectations, template);
|
|
102
105
|
});
|
|
103
|
-
it(
|
|
104
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
106
|
+
it("fail: previous template: invalid semver", function () {
|
|
107
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
105
108
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
106
|
-
let badTypeId =
|
|
109
|
+
let badTypeId = "TeamLeoValidation2:PointID-1.0.0.1";
|
|
107
110
|
templatePrevious.typeid = badTypeId;
|
|
108
111
|
let expectations = function (result) {
|
|
109
|
-
(0, chai_1.expect)(result).property(
|
|
112
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
110
113
|
(0, chai_1.expect)(result.typeid).to.equal(badTypeId);
|
|
111
114
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
112
115
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(`'${badTypeId}' is not valid`);
|
|
113
116
|
return result;
|
|
114
117
|
};
|
|
115
|
-
return validate(expectations, template, templatePrevious, false,
|
|
118
|
+
return validate(expectations, template, templatePrevious, false, "Invalid Version: 1.0.0.1");
|
|
116
119
|
});
|
|
117
120
|
});
|
|
118
121
|
// --- Template versioning ---
|
|
119
|
-
describe(
|
|
120
|
-
it(
|
|
121
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
122
|
+
describe("template versioning", function () {
|
|
123
|
+
it("fail: version regression: 1.0.0 -> 0.9.9", function () {
|
|
124
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
122
125
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
123
|
-
template.typeid =
|
|
126
|
+
template.typeid = "TeamLeoValidation2:PointID-0.9.9";
|
|
124
127
|
let expectations = function (result) {
|
|
125
|
-
(0, chai_1.expect)(result).property(
|
|
128
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
126
129
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
127
130
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.VERSION_REGRESSION_1);
|
|
128
131
|
return result;
|
|
129
132
|
};
|
|
130
133
|
return validate(expectations, template, templatePrevious);
|
|
131
134
|
});
|
|
132
|
-
describe(
|
|
133
|
-
it(
|
|
134
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
135
|
+
describe("same version", function () {
|
|
136
|
+
it("pass: same content", function () {
|
|
137
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
135
138
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
136
139
|
let expectations = function (result) {
|
|
137
|
-
(0, chai_1.expect)(result).property(
|
|
140
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
138
141
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
139
142
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
140
143
|
return result;
|
|
@@ -142,12 +145,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
142
145
|
return validate(expectations, template, templatePrevious);
|
|
143
146
|
});
|
|
144
147
|
it("fail: changed 'annotation'", function () {
|
|
145
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
146
|
-
templatePrevious.annotation = { description:
|
|
148
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
149
|
+
templatePrevious.annotation = { description: "Test" };
|
|
147
150
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
148
|
-
template.annotation.description =
|
|
151
|
+
template.annotation.description = "Changed!";
|
|
149
152
|
let expectations = function (result) {
|
|
150
|
-
(0, chai_1.expect)(result).property(
|
|
153
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
151
154
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
152
155
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1);
|
|
153
156
|
return result;
|
|
@@ -155,12 +158,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
155
158
|
return validate(expectations, template, templatePrevious);
|
|
156
159
|
});
|
|
157
160
|
it("fail: deleted 'annotation'", function () {
|
|
158
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
159
|
-
templatePrevious.annotation = { description:
|
|
161
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
162
|
+
templatePrevious.annotation = { description: "Test" };
|
|
160
163
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
161
164
|
delete template.annotation;
|
|
162
165
|
let expectations = function (result) {
|
|
163
|
-
(0, chai_1.expect)(result).property(
|
|
166
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
164
167
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
165
168
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1);
|
|
166
169
|
return result;
|
|
@@ -168,11 +171,11 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
168
171
|
return validate(expectations, template, templatePrevious);
|
|
169
172
|
});
|
|
170
173
|
it("fail: added 'annotation'", function () {
|
|
171
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
174
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
172
175
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
173
|
-
template.annotation = { description:
|
|
176
|
+
template.annotation = { description: "Test" };
|
|
174
177
|
let expectations = function (result) {
|
|
175
|
-
(0, chai_1.expect)(result).property(
|
|
178
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
176
179
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
177
180
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1);
|
|
178
181
|
return result;
|
|
@@ -180,11 +183,11 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
180
183
|
return validate(expectations, template, templatePrevious);
|
|
181
184
|
});
|
|
182
185
|
it("fail: changed 'value'", function () {
|
|
183
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
186
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodUIBorder")));
|
|
184
187
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
185
188
|
template.properties[0].properties[0].value = 123456;
|
|
186
189
|
let expectations = function (result) {
|
|
187
|
-
(0, chai_1.expect)(result).property(
|
|
190
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
188
191
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
189
192
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1);
|
|
190
193
|
return result;
|
|
@@ -192,11 +195,11 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
192
195
|
return validate(expectations, template, templatePrevious);
|
|
193
196
|
});
|
|
194
197
|
it("fail: changed 'id'", function () {
|
|
195
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
198
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
196
199
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
197
|
-
template.properties[0].properties[0].id =
|
|
200
|
+
template.properties[0].properties[0].id = "xx";
|
|
198
201
|
let expectations = function (result) {
|
|
199
|
-
(0, chai_1.expect)(result).property(
|
|
202
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
200
203
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
201
204
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1);
|
|
202
205
|
return result;
|
|
@@ -204,37 +207,37 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
204
207
|
return validate(expectations, template, templatePrevious);
|
|
205
208
|
});
|
|
206
209
|
it("fail: changed 'inherits'", function () {
|
|
207
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
210
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodReservedTypes")));
|
|
208
211
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
209
|
-
template.inherits =
|
|
212
|
+
template.inherits = "Reference<Adsk.Core:Math.Color-1.0.0>";
|
|
210
213
|
let expectations = function (result) {
|
|
211
|
-
(0, chai_1.expect)(result).property(
|
|
214
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
212
215
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
213
216
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1);
|
|
214
217
|
return result;
|
|
215
218
|
};
|
|
216
219
|
return validate(expectations, template, templatePrevious);
|
|
217
220
|
});
|
|
218
|
-
it(
|
|
219
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
220
|
-
templatePrevious.annotation = { description:
|
|
221
|
+
it("fail: added property", function () {
|
|
222
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
223
|
+
templatePrevious.annotation = { description: "Test" };
|
|
221
224
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
222
|
-
template.properties[0].properties.push({
|
|
225
|
+
template.properties[0].properties.push({ id: "newPropId", typeid: "Float32" });
|
|
223
226
|
let expectations = function (result) {
|
|
224
|
-
(0, chai_1.expect)(result).property(
|
|
227
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
225
228
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
226
229
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1);
|
|
227
230
|
return result;
|
|
228
231
|
};
|
|
229
232
|
return validate(expectations, template, templatePrevious);
|
|
230
233
|
});
|
|
231
|
-
it(
|
|
232
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
233
|
-
templatePrevious.annotation = { description:
|
|
234
|
+
it("fail: deleted property", function () {
|
|
235
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
236
|
+
templatePrevious.annotation = { description: "Test" };
|
|
234
237
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
235
238
|
template.properties[0].properties.pop();
|
|
236
239
|
let expectations = function (result) {
|
|
237
|
-
(0, chai_1.expect)(result).property(
|
|
240
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
238
241
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
239
242
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1);
|
|
240
243
|
return result;
|
|
@@ -242,27 +245,27 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
242
245
|
return validate(expectations, template, templatePrevious);
|
|
243
246
|
});
|
|
244
247
|
});
|
|
245
|
-
describe(
|
|
246
|
-
it(
|
|
247
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
248
|
+
describe("incremented patch level", function () {
|
|
249
|
+
it("pass: same content", function () {
|
|
250
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
248
251
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
249
|
-
template.typeid =
|
|
252
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "patch");
|
|
250
253
|
let expectations = function (result) {
|
|
251
|
-
(0, chai_1.expect)(result).property(
|
|
254
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
252
255
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
253
256
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
254
257
|
return result;
|
|
255
258
|
};
|
|
256
259
|
return validate(expectations, template, templatePrevious);
|
|
257
260
|
});
|
|
258
|
-
it(
|
|
259
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
260
|
-
templatePrevious.typeid =
|
|
261
|
+
it("pass: unstable with major content change: 0.0.1 -> 0.0.2", function () {
|
|
262
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
263
|
+
templatePrevious.typeid = "TeamLeoValidation2:PointID-0.0.1";
|
|
261
264
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
262
|
-
template.typeid =
|
|
263
|
-
template.properties[1].typeid =
|
|
265
|
+
template.typeid = "TeamLeoValidation2:PointID-0.0.2";
|
|
266
|
+
template.properties[1].typeid = "TeamLeoValidation2:ColorID-9.0.0";
|
|
264
267
|
let expectations = function (result) {
|
|
265
|
-
(0, chai_1.expect)(result).property(
|
|
268
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
266
269
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
267
270
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
268
271
|
return result;
|
|
@@ -270,13 +273,13 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
270
273
|
return validate(expectations, template, templatePrevious);
|
|
271
274
|
});
|
|
272
275
|
it("pass: changed 'annotation'", function () {
|
|
273
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
274
|
-
templatePrevious.annotation = { description:
|
|
276
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
277
|
+
templatePrevious.annotation = { description: "Test" };
|
|
275
278
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
276
|
-
template.typeid =
|
|
277
|
-
template.annotation.description =
|
|
279
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "patch");
|
|
280
|
+
template.annotation.description = "Changed!";
|
|
278
281
|
let expectations = function (result) {
|
|
279
|
-
(0, chai_1.expect)(result).property(
|
|
282
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
280
283
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
281
284
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
282
285
|
return result;
|
|
@@ -284,13 +287,13 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
284
287
|
return validate(expectations, template, templatePrevious);
|
|
285
288
|
});
|
|
286
289
|
it("pass: deleted 'annotation'", function () {
|
|
287
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
288
|
-
templatePrevious.annotation = { description:
|
|
290
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
291
|
+
templatePrevious.annotation = { description: "Test" };
|
|
289
292
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
290
|
-
template.typeid =
|
|
293
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "patch");
|
|
291
294
|
delete template.annotation;
|
|
292
295
|
let expectations = function (result) {
|
|
293
|
-
(0, chai_1.expect)(result).property(
|
|
296
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
294
297
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
295
298
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
296
299
|
return result;
|
|
@@ -298,12 +301,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
298
301
|
return validate(expectations, template, templatePrevious);
|
|
299
302
|
});
|
|
300
303
|
it("pass: added 'annotation'", function () {
|
|
301
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
304
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
302
305
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
303
|
-
template.typeid =
|
|
304
|
-
template.annotation = { description:
|
|
306
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "patch");
|
|
307
|
+
template.annotation = { description: "Test" };
|
|
305
308
|
let expectations = function (result) {
|
|
306
|
-
(0, chai_1.expect)(result).property(
|
|
309
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
307
310
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
308
311
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
309
312
|
return result;
|
|
@@ -311,12 +314,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
311
314
|
return validate(expectations, template, templatePrevious);
|
|
312
315
|
});
|
|
313
316
|
it("warn: changed 'value'", function () {
|
|
314
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
317
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodUIBorder")));
|
|
315
318
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
316
|
-
template.typeid =
|
|
319
|
+
template.typeid = "Adsk.Core:UI.Border-" + semver.inc("1.0.0", "patch");
|
|
317
320
|
template.properties[0].properties[0].value = 123456;
|
|
318
321
|
let expectations = function (result) {
|
|
319
|
-
(0, chai_1.expect)(result).property(
|
|
322
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
320
323
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
321
324
|
(0, chai_1.expect)(result.warnings.length).to.be.at.least(1);
|
|
322
325
|
(0, chai_1.expect)(result.warnings[0]).to.have.string(MSG.CHANGE_LEVEL_TOO_LOW_1);
|
|
@@ -325,12 +328,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
325
328
|
return validate(expectations, template, templatePrevious);
|
|
326
329
|
});
|
|
327
330
|
it("warn: changed 'id' (delete, add)", function () {
|
|
328
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
331
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
329
332
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
330
|
-
template.typeid =
|
|
331
|
-
template.properties[0].properties[0].id =
|
|
333
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "patch");
|
|
334
|
+
template.properties[0].properties[0].id = "xx";
|
|
332
335
|
let expectations = function (result) {
|
|
333
|
-
(0, chai_1.expect)(result).property(
|
|
336
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
334
337
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
335
338
|
(0, chai_1.expect)(result.warnings.length).to.be.at.least(2); // 1st for the delete and the 2nd for the add
|
|
336
339
|
(0, chai_1.expect)(result.warnings[0]).to.have.string(MSG.CHANGE_LEVEL_TOO_LOW_1);
|
|
@@ -339,12 +342,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
339
342
|
return validate(expectations, template, templatePrevious);
|
|
340
343
|
});
|
|
341
344
|
it("warn: changed 'inherits'", function () {
|
|
342
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
345
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodReservedTypes")));
|
|
343
346
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
344
|
-
template.typeid =
|
|
345
|
-
template.inherits =
|
|
347
|
+
template.typeid = "TeamLeoValidation2:Example-" + semver.inc("1.0.0", "patch");
|
|
348
|
+
template.inherits = "Reference<Adsk.Core:Math.Color-1.0.0>";
|
|
346
349
|
let expectations = function (result) {
|
|
347
|
-
(0, chai_1.expect)(result).property(
|
|
350
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
348
351
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
349
352
|
(0, chai_1.expect)(result.warnings.length).to.be.at.least(1);
|
|
350
353
|
(0, chai_1.expect)(result.warnings[0]).to.have.string(MSG.CHANGE_LEVEL_TOO_LOW_1);
|
|
@@ -352,14 +355,14 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
352
355
|
};
|
|
353
356
|
return validate(expectations, template, templatePrevious);
|
|
354
357
|
});
|
|
355
|
-
it(
|
|
356
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
357
|
-
templatePrevious.annotation = { description:
|
|
358
|
+
it("warn: added property", function () {
|
|
359
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
360
|
+
templatePrevious.annotation = { description: "Test" };
|
|
358
361
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
359
|
-
template.typeid =
|
|
360
|
-
template.properties[0].properties.push({
|
|
362
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "patch");
|
|
363
|
+
template.properties[0].properties.push({ id: "newPropId", typeid: "Float32" });
|
|
361
364
|
let expectations = function (result) {
|
|
362
|
-
(0, chai_1.expect)(result).property(
|
|
365
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
363
366
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
364
367
|
(0, chai_1.expect)(result.warnings.length).to.be.at.least(1);
|
|
365
368
|
(0, chai_1.expect)(result.warnings[0]).to.have.string(MSG.CHANGE_LEVEL_TOO_LOW_1);
|
|
@@ -367,14 +370,14 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
367
370
|
};
|
|
368
371
|
return validate(expectations, template, templatePrevious);
|
|
369
372
|
});
|
|
370
|
-
it(
|
|
371
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
372
|
-
templatePrevious.annotation = { description:
|
|
373
|
+
it("warn: deleted property", function () {
|
|
374
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
375
|
+
templatePrevious.annotation = { description: "Test" };
|
|
373
376
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
374
|
-
template.typeid =
|
|
377
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "patch");
|
|
375
378
|
template.properties[0].properties.pop();
|
|
376
379
|
let expectations = function (result) {
|
|
377
|
-
(0, chai_1.expect)(result).property(
|
|
380
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
378
381
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
379
382
|
(0, chai_1.expect)(result.warnings.length).to.be.at.least(1);
|
|
380
383
|
(0, chai_1.expect)(result.warnings[0]).to.have.string(MSG.CHANGE_LEVEL_TOO_LOW_1);
|
|
@@ -383,13 +386,13 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
383
386
|
return validate(expectations, template, templatePrevious);
|
|
384
387
|
});
|
|
385
388
|
});
|
|
386
|
-
describe(
|
|
387
|
-
it(
|
|
388
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
389
|
+
describe("incremented minor level", function () {
|
|
390
|
+
it("pass: same content", function () {
|
|
391
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
389
392
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
390
|
-
template.typeid =
|
|
393
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "minor");
|
|
391
394
|
let expectations = function (result) {
|
|
392
|
-
(0, chai_1.expect)(result).property(
|
|
395
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
393
396
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
394
397
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
395
398
|
return result;
|
|
@@ -397,13 +400,13 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
397
400
|
return validate(expectations, template, templatePrevious);
|
|
398
401
|
});
|
|
399
402
|
it("pass: changed 'annotation'", function () {
|
|
400
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
401
|
-
templatePrevious.annotation = { description:
|
|
403
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
404
|
+
templatePrevious.annotation = { description: "Test" };
|
|
402
405
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
403
|
-
template.typeid =
|
|
404
|
-
template.annotation.description =
|
|
406
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "minor");
|
|
407
|
+
template.annotation.description = "Changed!";
|
|
405
408
|
let expectations = function (result) {
|
|
406
|
-
(0, chai_1.expect)(result).property(
|
|
409
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
407
410
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
408
411
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
409
412
|
return result;
|
|
@@ -411,13 +414,13 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
411
414
|
return validate(expectations, template, templatePrevious);
|
|
412
415
|
});
|
|
413
416
|
it("pass: deleted 'annotation'", function () {
|
|
414
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
415
|
-
templatePrevious.annotation = { description:
|
|
417
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
418
|
+
templatePrevious.annotation = { description: "Test" };
|
|
416
419
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
417
|
-
template.typeid =
|
|
420
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "minor");
|
|
418
421
|
delete template.annotation;
|
|
419
422
|
let expectations = function (result) {
|
|
420
|
-
(0, chai_1.expect)(result).property(
|
|
423
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
421
424
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
422
425
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
423
426
|
return result;
|
|
@@ -425,12 +428,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
425
428
|
return validate(expectations, template, templatePrevious);
|
|
426
429
|
});
|
|
427
430
|
it("pass: added 'annotation'", function () {
|
|
428
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
431
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
429
432
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
430
|
-
template.typeid =
|
|
431
|
-
template.annotation = { description:
|
|
433
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "minor");
|
|
434
|
+
template.annotation = { description: "Test" };
|
|
432
435
|
let expectations = function (result) {
|
|
433
|
-
(0, chai_1.expect)(result).property(
|
|
436
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
434
437
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
435
438
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
436
439
|
return result;
|
|
@@ -438,12 +441,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
438
441
|
return validate(expectations, template, templatePrevious);
|
|
439
442
|
});
|
|
440
443
|
it("pass: changed 'value'", function () {
|
|
441
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
444
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodUIBorder")));
|
|
442
445
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
443
|
-
template.typeid =
|
|
446
|
+
template.typeid = "Adsk.Core:UI.Border-" + semver.inc("1.0.0", "minor");
|
|
444
447
|
template.properties[0].properties[0].value = 123456;
|
|
445
448
|
let expectations = function (result) {
|
|
446
|
-
(0, chai_1.expect)(result).property(
|
|
449
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
447
450
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
448
451
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
449
452
|
return result;
|
|
@@ -451,12 +454,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
451
454
|
return validate(expectations, template, templatePrevious);
|
|
452
455
|
});
|
|
453
456
|
it("warn: changed 'id' (delete, add)", function () {
|
|
454
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
457
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
455
458
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
456
|
-
template.typeid =
|
|
457
|
-
template.properties[0].properties[0].id =
|
|
459
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "minor");
|
|
460
|
+
template.properties[0].properties[0].id = "xx";
|
|
458
461
|
let expectations = function (result) {
|
|
459
|
-
(0, chai_1.expect)(result).property(
|
|
462
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
460
463
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
461
464
|
(0, chai_1.expect)(result.warnings.length).to.be.at.least(1);
|
|
462
465
|
(0, chai_1.expect)(result.warnings[0]).to.have.string(MSG.CHANGE_LEVEL_TOO_LOW_1);
|
|
@@ -465,12 +468,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
465
468
|
return validate(expectations, template, templatePrevious);
|
|
466
469
|
});
|
|
467
470
|
it("warn: changed 'inherits'", function () {
|
|
468
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
471
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodReservedTypes")));
|
|
469
472
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
470
|
-
template.typeid =
|
|
471
|
-
template.inherits =
|
|
473
|
+
template.typeid = "TeamLeoValidation2:Example-" + semver.inc("1.0.0", "minor");
|
|
474
|
+
template.inherits = "Reference<Adsk.Core:Math.Color-1.0.0>";
|
|
472
475
|
let expectations = function (result) {
|
|
473
|
-
(0, chai_1.expect)(result).property(
|
|
476
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
474
477
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
475
478
|
(0, chai_1.expect)(result.warnings.length).to.be.at.least(1);
|
|
476
479
|
(0, chai_1.expect)(result.warnings[0]).to.have.string(MSG.CHANGE_LEVEL_TOO_LOW_1);
|
|
@@ -478,28 +481,28 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
478
481
|
};
|
|
479
482
|
return validate(expectations, template, templatePrevious);
|
|
480
483
|
});
|
|
481
|
-
it(
|
|
482
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
483
|
-
templatePrevious.annotation = { description:
|
|
484
|
+
it("pass: added property", function () {
|
|
485
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
486
|
+
templatePrevious.annotation = { description: "Test" };
|
|
484
487
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
485
|
-
template.typeid =
|
|
486
|
-
template.properties[0].properties.push({
|
|
488
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "minor");
|
|
489
|
+
template.properties[0].properties.push({ id: "newPropId", typeid: "Float32" });
|
|
487
490
|
let expectations = function (result) {
|
|
488
|
-
(0, chai_1.expect)(result).property(
|
|
491
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
489
492
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
490
493
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
491
494
|
return result;
|
|
492
495
|
};
|
|
493
496
|
return validate(expectations, template, templatePrevious);
|
|
494
497
|
});
|
|
495
|
-
it(
|
|
496
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
497
|
-
templatePrevious.annotation = { description:
|
|
498
|
+
it("warn: deleted property", function () {
|
|
499
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
500
|
+
templatePrevious.annotation = { description: "Test" };
|
|
498
501
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
499
|
-
template.typeid =
|
|
502
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "minor");
|
|
500
503
|
template.properties[0].properties.pop();
|
|
501
504
|
let expectations = function (result) {
|
|
502
|
-
(0, chai_1.expect)(result).property(
|
|
505
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
503
506
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
504
507
|
(0, chai_1.expect)(result.warnings.length).to.be.at.least(1);
|
|
505
508
|
(0, chai_1.expect)(result.warnings[0]).to.have.string(MSG.CHANGE_LEVEL_TOO_LOW_1);
|
|
@@ -508,13 +511,13 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
508
511
|
return validate(expectations, template, templatePrevious);
|
|
509
512
|
});
|
|
510
513
|
});
|
|
511
|
-
describe(
|
|
512
|
-
it(
|
|
513
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
514
|
+
describe("incremented major level", function () {
|
|
515
|
+
it("pass: same content", function () {
|
|
516
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
514
517
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
515
|
-
template.typeid =
|
|
518
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "major");
|
|
516
519
|
let expectations = function (result) {
|
|
517
|
-
(0, chai_1.expect)(result).property(
|
|
520
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
518
521
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
519
522
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
520
523
|
return result;
|
|
@@ -522,13 +525,13 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
522
525
|
return validate(expectations, template, templatePrevious);
|
|
523
526
|
});
|
|
524
527
|
it("pass: changed 'annotation'", function () {
|
|
525
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
526
|
-
templatePrevious.annotation = { description:
|
|
528
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
529
|
+
templatePrevious.annotation = { description: "Test" };
|
|
527
530
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
528
|
-
template.typeid =
|
|
529
|
-
template.annotation.description =
|
|
531
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "major");
|
|
532
|
+
template.annotation.description = "Changed!";
|
|
530
533
|
let expectations = function (result) {
|
|
531
|
-
(0, chai_1.expect)(result).property(
|
|
534
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
532
535
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
533
536
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
534
537
|
return result;
|
|
@@ -536,13 +539,13 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
536
539
|
return validate(expectations, template, templatePrevious);
|
|
537
540
|
});
|
|
538
541
|
it("pass: deleted 'annotation'", function () {
|
|
539
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
540
|
-
templatePrevious.annotation = { description:
|
|
542
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
543
|
+
templatePrevious.annotation = { description: "Test" };
|
|
541
544
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
542
|
-
template.typeid =
|
|
545
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "major");
|
|
543
546
|
delete template.annotation;
|
|
544
547
|
let expectations = function (result) {
|
|
545
|
-
(0, chai_1.expect)(result).property(
|
|
548
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
546
549
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
547
550
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
548
551
|
return result;
|
|
@@ -550,12 +553,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
550
553
|
return validate(expectations, template, templatePrevious);
|
|
551
554
|
});
|
|
552
555
|
it("pass: added 'annotation'", function () {
|
|
553
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
556
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
554
557
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
555
|
-
template.typeid =
|
|
556
|
-
template.annotation = { description:
|
|
558
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "major");
|
|
559
|
+
template.annotation = { description: "Test" };
|
|
557
560
|
let expectations = function (result) {
|
|
558
|
-
(0, chai_1.expect)(result).property(
|
|
561
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
559
562
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
560
563
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
561
564
|
return result;
|
|
@@ -563,12 +566,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
563
566
|
return validate(expectations, template, templatePrevious);
|
|
564
567
|
});
|
|
565
568
|
it("pass: changed 'value'", function () {
|
|
566
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
569
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodUIBorder")));
|
|
567
570
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
568
|
-
template.typeid =
|
|
571
|
+
template.typeid = "Adsk.Core:UI.Border-" + semver.inc("1.0.0", "major");
|
|
569
572
|
template.properties[0].properties[0].value = 123456;
|
|
570
573
|
let expectations = function (result) {
|
|
571
|
-
(0, chai_1.expect)(result).property(
|
|
574
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
572
575
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
573
576
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
574
577
|
return result;
|
|
@@ -576,12 +579,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
576
579
|
return validate(expectations, template, templatePrevious);
|
|
577
580
|
});
|
|
578
581
|
it("pass: changed 'id' (delete, add)", function () {
|
|
579
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
582
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
580
583
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
581
|
-
template.typeid =
|
|
582
|
-
template.properties[0].properties[0].id =
|
|
584
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "major");
|
|
585
|
+
template.properties[0].properties[0].id = "xx";
|
|
583
586
|
let expectations = function (result) {
|
|
584
|
-
(0, chai_1.expect)(result).property(
|
|
587
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
585
588
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
586
589
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
587
590
|
return result;
|
|
@@ -589,40 +592,40 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
589
592
|
return validate(expectations, template, templatePrevious);
|
|
590
593
|
});
|
|
591
594
|
it("pass: changed 'inherits'", function () {
|
|
592
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
595
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodReservedTypes")));
|
|
593
596
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
594
|
-
template.typeid =
|
|
595
|
-
template.inherits =
|
|
597
|
+
template.typeid = "TeamLeoValidation2:Example-" + semver.inc("1.0.0", "major");
|
|
598
|
+
template.inherits = "Reference<Adsk.Core:Math.Color-1.0.0>";
|
|
596
599
|
let expectations = function (result) {
|
|
597
|
-
(0, chai_1.expect)(result).property(
|
|
600
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
598
601
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
599
602
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
600
603
|
return result;
|
|
601
604
|
};
|
|
602
605
|
return validate(expectations, template, templatePrevious);
|
|
603
606
|
});
|
|
604
|
-
it(
|
|
605
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
606
|
-
templatePrevious.annotation = { description:
|
|
607
|
+
it("pass: added property", function () {
|
|
608
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
609
|
+
templatePrevious.annotation = { description: "Test" };
|
|
607
610
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
608
|
-
template.typeid =
|
|
609
|
-
template.properties[0].properties.push({
|
|
611
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "major");
|
|
612
|
+
template.properties[0].properties.push({ id: "newPropId", typeid: "Float32" });
|
|
610
613
|
let expectations = function (result) {
|
|
611
|
-
(0, chai_1.expect)(result).property(
|
|
614
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
612
615
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
613
616
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
614
617
|
return result;
|
|
615
618
|
};
|
|
616
619
|
return validate(expectations, template, templatePrevious);
|
|
617
620
|
});
|
|
618
|
-
it(
|
|
619
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
620
|
-
templatePrevious.annotation = { description:
|
|
621
|
+
it("pass: deleted property", function () {
|
|
622
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
623
|
+
templatePrevious.annotation = { description: "Test" };
|
|
621
624
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
622
|
-
template.typeid =
|
|
625
|
+
template.typeid = "TeamLeoValidation2:PointID-" + semver.inc("1.0.0", "major");
|
|
623
626
|
template.properties[0].properties.pop();
|
|
624
627
|
let expectations = function (result) {
|
|
625
|
-
(0, chai_1.expect)(result).property(
|
|
628
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
626
629
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
627
630
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
628
631
|
return result;
|
|
@@ -631,9 +634,9 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
631
634
|
});
|
|
632
635
|
});
|
|
633
636
|
});
|
|
634
|
-
describe(
|
|
635
|
-
it(
|
|
636
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
637
|
+
describe("skip semver validation", function () {
|
|
638
|
+
it("pass: deep equal on scrambled arrays", function () {
|
|
639
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
637
640
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
638
641
|
let tmp = template.properties[0].properties[0];
|
|
639
642
|
template.properties[0].properties[0] = template.properties[0].properties[2];
|
|
@@ -643,33 +646,33 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
643
646
|
template.properties[2] = tmp;
|
|
644
647
|
// Skip semver validation to cause a deep compare
|
|
645
648
|
let expectations = function (result) {
|
|
646
|
-
(0, chai_1.expect)(result).property(
|
|
649
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
647
650
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
648
651
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
649
652
|
return result;
|
|
650
653
|
};
|
|
651
654
|
return validate(expectations, template, templatePrevious, true);
|
|
652
655
|
});
|
|
653
|
-
it(
|
|
654
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
656
|
+
it("pass: deep equal with version regression", function () {
|
|
657
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
655
658
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
656
659
|
let expectations = function (result) {
|
|
657
|
-
(0, chai_1.expect)(result).property(
|
|
660
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
658
661
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
659
662
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
660
663
|
return result;
|
|
661
664
|
};
|
|
662
665
|
return validate(expectations, template, templatePrevious, true);
|
|
663
666
|
});
|
|
664
|
-
it(
|
|
665
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
667
|
+
it("pass: preserves input templates", function () {
|
|
668
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodPointId")));
|
|
666
669
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
667
670
|
let copies = [
|
|
668
671
|
JSON.parse(JSON.stringify(templatePrevious)),
|
|
669
672
|
JSON.parse(JSON.stringify(template)),
|
|
670
673
|
];
|
|
671
674
|
let expectations = function (result) {
|
|
672
|
-
(0, chai_1.expect)(result).property(
|
|
675
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
673
676
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
674
677
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
675
678
|
(0, chai_1.expect)(templatePrevious).to.deep.equal(copies[0]);
|
|
@@ -678,12 +681,12 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
678
681
|
};
|
|
679
682
|
return validate(expectations, template, templatePrevious);
|
|
680
683
|
});
|
|
681
|
-
it(
|
|
682
|
-
let templatePrevious = JSON.parse(JSON.stringify(require(
|
|
684
|
+
it("fail: changed value", function () {
|
|
685
|
+
let templatePrevious = JSON.parse(JSON.stringify(require("../schemas/goodUIBorder")));
|
|
683
686
|
let template = JSON.parse(JSON.stringify(templatePrevious));
|
|
684
687
|
template.properties[0].properties[0].value = 123456;
|
|
685
688
|
let expectations = function (result) {
|
|
686
|
-
(0, chai_1.expect)(result).property(
|
|
689
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
687
690
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
688
691
|
(0, chai_1.expect)(result.errors.length).to.be.at.least(1);
|
|
689
692
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_1);
|
|
@@ -692,17 +695,17 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
692
695
|
return validate(expectations, template, templatePrevious, true);
|
|
693
696
|
});
|
|
694
697
|
});
|
|
695
|
-
describe(
|
|
696
|
-
it(
|
|
697
|
-
let template = require(
|
|
698
|
+
describe("syntax validation", function () {
|
|
699
|
+
it("pass: validate a simple file", function () {
|
|
700
|
+
let template = require("../schemas/goodPointId");
|
|
698
701
|
let expectations = function (result) {
|
|
699
702
|
(0, chai_1.expect)(result.isValid).to.equal(true);
|
|
700
703
|
return result;
|
|
701
704
|
};
|
|
702
705
|
return validate(expectations, template, null, true);
|
|
703
706
|
});
|
|
704
|
-
it(
|
|
705
|
-
let template = require(
|
|
707
|
+
it("fail: invalid file", function () {
|
|
708
|
+
let template = require("../schemas/badPrimitiveTypeid");
|
|
706
709
|
let expectations = function (result) {
|
|
707
710
|
(0, chai_1.expect)(result.isValid).to.equal(false);
|
|
708
711
|
(0, chai_1.expect)(result.errors.length).to.be.greaterThan(0);
|
|
@@ -711,9 +714,9 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
711
714
|
};
|
|
712
715
|
return validate(expectations, template, null, true);
|
|
713
716
|
});
|
|
714
|
-
it(
|
|
717
|
+
it("should pass a schema with an empty array of properties", function () {
|
|
715
718
|
let EmptyPropertySchema = {
|
|
716
|
-
typeid:
|
|
719
|
+
typeid: "Test:EmptyPropertySchema-1.0.0",
|
|
717
720
|
properties: [],
|
|
718
721
|
};
|
|
719
722
|
let expectations = function (result) {
|
|
@@ -723,27 +726,27 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
723
726
|
return validate(expectations, EmptyPropertySchema, null);
|
|
724
727
|
});
|
|
725
728
|
});
|
|
726
|
-
describe(
|
|
727
|
-
describe(
|
|
728
|
-
it(
|
|
729
|
+
describe("bugs", function () {
|
|
730
|
+
describe("@bugfix Template validation with multiple inheritance", function () {
|
|
731
|
+
it("pass: deep equal with multiple inheritance", function () {
|
|
729
732
|
let templateString = '{"typeid":"autodesk.core:translation.controller-1.0.0","inherits":["NamedProperty","NodeProperty"]}';
|
|
730
733
|
let templatePrevious = JSON.parse(templateString);
|
|
731
734
|
let template = JSON.parse(templateString);
|
|
732
735
|
let expectations = function (result) {
|
|
733
|
-
(0, chai_1.expect)(result).property(
|
|
736
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
734
737
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
735
738
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
736
739
|
return result;
|
|
737
740
|
};
|
|
738
741
|
return validate(expectations, template, templatePrevious, true);
|
|
739
742
|
});
|
|
740
|
-
it(
|
|
743
|
+
it("fail: deep equal with out of order multiple inheritance", function () {
|
|
741
744
|
let template = JSON.parse('{"typeid":"autodesk.core:translation.controller-1.0.0",' +
|
|
742
745
|
'"inherits":["NamedProperty","NodeProperty"]}');
|
|
743
746
|
let templatePrevious = JSON.parse('{"typeid":"autodesk.core:translation.controller-1.0.0",' +
|
|
744
747
|
'"inherits":["NodeProperty","NamedProperty"]}');
|
|
745
748
|
let expectations = function (result) {
|
|
746
|
-
(0, chai_1.expect)(result).property(
|
|
749
|
+
(0, chai_1.expect)(result).property("isValid", false);
|
|
747
750
|
(0, chai_1.expect)(result.errors.length).to.be.greaterThan(0);
|
|
748
751
|
(0, chai_1.expect)(result.errors[0].message).to.have.string(MSG.MODIFIED_TEMPLATE_1);
|
|
749
752
|
return result;
|
|
@@ -751,28 +754,28 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
751
754
|
return validate(expectations, template, templatePrevious, true);
|
|
752
755
|
});
|
|
753
756
|
});
|
|
754
|
-
describe(
|
|
755
|
-
|
|
756
|
-
describe(
|
|
757
|
+
describe("@bugfix Local templates with 'abstract' properties fail validation " +
|
|
758
|
+
"with remote one.", () => {
|
|
759
|
+
describe("pass: deep equal between no properties and an empty properties array", () => {
|
|
757
760
|
let templateArray = {
|
|
758
|
-
typeid:
|
|
761
|
+
typeid: "SimpleTest:Shape-1.0.0",
|
|
759
762
|
properties: [],
|
|
760
763
|
};
|
|
761
764
|
let templateAbstract = {
|
|
762
|
-
typeid:
|
|
765
|
+
typeid: "SimpleTest:Shape-1.0.0",
|
|
763
766
|
};
|
|
764
|
-
it(
|
|
767
|
+
it("source is abstract and target is an empty properties array", function () {
|
|
765
768
|
let expectations = function (result) {
|
|
766
|
-
(0, chai_1.expect)(result).property(
|
|
769
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
767
770
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
768
771
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
769
772
|
return result;
|
|
770
773
|
};
|
|
771
774
|
return validate(expectations, templateAbstract, templateArray);
|
|
772
775
|
});
|
|
773
|
-
it(
|
|
776
|
+
it("target is abstract and source is an empty properties array", function () {
|
|
774
777
|
let expectations = function (result) {
|
|
775
|
-
(0, chai_1.expect)(result).property(
|
|
778
|
+
(0, chai_1.expect)(result).property("isValid", true);
|
|
776
779
|
(0, chai_1.expect)(result.errors).to.be.empty;
|
|
777
780
|
(0, chai_1.expect)(result.warnings).to.be.empty;
|
|
778
781
|
return result;
|
|
@@ -782,7 +785,7 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
782
785
|
});
|
|
783
786
|
});
|
|
784
787
|
});
|
|
785
|
-
describe(
|
|
788
|
+
describe("Constants", function () {
|
|
786
789
|
before(function () {
|
|
787
790
|
let schemaValidator = new schemaValidator_1.SchemaValidator();
|
|
788
791
|
new templateValidator_1.TemplateValidator({
|
|
@@ -799,10 +802,10 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
799
802
|
return result;
|
|
800
803
|
};
|
|
801
804
|
};
|
|
802
|
-
it(
|
|
805
|
+
it("should pass a valid template", function () {
|
|
803
806
|
let ConstantValid = {
|
|
804
|
-
typeid:
|
|
805
|
-
constants: [{ id:
|
|
807
|
+
typeid: "ConstantTest:ConstantValid-1.0.0",
|
|
808
|
+
constants: [{ id: "valid", typeid: "String", value: "value" }],
|
|
806
809
|
};
|
|
807
810
|
let expectations = function (result) {
|
|
808
811
|
(0, chai_1.expect)(result.isValid).to.equal(true);
|
|
@@ -810,24 +813,24 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
810
813
|
};
|
|
811
814
|
return validate(expectations, ConstantValid, null);
|
|
812
815
|
});
|
|
813
|
-
it(
|
|
816
|
+
it("should fail if constants array has no elements", function () {
|
|
814
817
|
let ConstantEmptyArray = {
|
|
815
|
-
typeid:
|
|
818
|
+
typeid: "ConstantTest:ConstantEmptyArray-1.0.0",
|
|
816
819
|
constants: [],
|
|
817
820
|
};
|
|
818
|
-
return validate(expectationsGenerator(
|
|
821
|
+
return validate(expectationsGenerator("/constants should NOT have fewer than 1 items"), ConstantEmptyArray, null, true);
|
|
819
822
|
});
|
|
820
|
-
it(
|
|
823
|
+
it("should fail if constant does not have an id", function () {
|
|
821
824
|
let ConstantNoId = {
|
|
822
|
-
typeid:
|
|
823
|
-
constants: [{ typeid:
|
|
825
|
+
typeid: "ConstantTest:ConstantNoId-1.0.0",
|
|
826
|
+
constants: [{ typeid: "String", value: "value" }],
|
|
824
827
|
};
|
|
825
|
-
return validate(expectationsGenerator(
|
|
828
|
+
return validate(expectationsGenerator("/constants/0 should have required property 'id'"), ConstantNoId, null, true);
|
|
826
829
|
});
|
|
827
|
-
it(
|
|
830
|
+
it("should fail if constant does not have a typeid", function () {
|
|
828
831
|
let ConstantNoTypeid = {
|
|
829
|
-
typeid:
|
|
830
|
-
constants: [{ id:
|
|
832
|
+
typeid: "ConstantTest:ConstantNoTypeid-1.0.0",
|
|
833
|
+
constants: [{ id: "id", value: "value" }],
|
|
831
834
|
};
|
|
832
835
|
return validate(function (result) {
|
|
833
836
|
(0, chai_1.expect)(result.isValid).to.equal(false);
|
|
@@ -838,11 +841,11 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
838
841
|
return result;
|
|
839
842
|
}, ConstantNoTypeid, null, true);
|
|
840
843
|
});
|
|
841
|
-
it(
|
|
844
|
+
it("should pass if constant does not have a typeid but maybe inherits from elsewhere", function () {
|
|
842
845
|
let ConstantNoTypeid = {
|
|
843
|
-
typeid:
|
|
844
|
-
inherits:
|
|
845
|
-
constants: [{ id:
|
|
846
|
+
typeid: "ConstantTest:ConstantNoTypeid-1.0.0",
|
|
847
|
+
inherits: "ConstantTest:ConstantParentWithTypeid-1.0.0",
|
|
848
|
+
constants: [{ id: "id", value: "value" }],
|
|
846
849
|
};
|
|
847
850
|
let expectations = function (result) {
|
|
848
851
|
(0, chai_1.expect)(result.isValid).to.equal(true);
|
|
@@ -850,10 +853,10 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
850
853
|
};
|
|
851
854
|
return validate(expectations, ConstantNoTypeid, null);
|
|
852
855
|
});
|
|
853
|
-
it(
|
|
856
|
+
it("should not fail if constant does not have a value or typedValue", function () {
|
|
854
857
|
let ConstantNoValue = {
|
|
855
|
-
typeid:
|
|
856
|
-
constants: [{ id:
|
|
858
|
+
typeid: "ConstantTest:ConstantNoValue-1.0.0",
|
|
859
|
+
constants: [{ id: "id", typeid: "String" }],
|
|
857
860
|
};
|
|
858
861
|
let expectations = function (result) {
|
|
859
862
|
(0, chai_1.expect)(result.isValid).to.equal(true);
|
|
@@ -861,16 +864,21 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
861
864
|
};
|
|
862
865
|
return validate(expectations, ConstantNoValue, null, true);
|
|
863
866
|
});
|
|
864
|
-
it(
|
|
867
|
+
it("should pass if constant map with context key type typeid has typeids as keys", function () {
|
|
865
868
|
let Constant = {
|
|
866
|
-
typeid:
|
|
867
|
-
constants: [
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
869
|
+
typeid: "ConstantTest:Constant-1.0.0",
|
|
870
|
+
constants: [
|
|
871
|
+
{
|
|
872
|
+
id: "map",
|
|
873
|
+
typeid: "Int32",
|
|
874
|
+
context: "map",
|
|
875
|
+
contextKeyType: "typeid",
|
|
876
|
+
value: {
|
|
877
|
+
"SimpleTest:ConstantTemplate1-1.0.0": 1,
|
|
878
|
+
"SimpleTest:ConstantTemplate2-1.0.0": -1,
|
|
879
|
+
},
|
|
880
|
+
},
|
|
881
|
+
],
|
|
874
882
|
};
|
|
875
883
|
let expectations = function (result) {
|
|
876
884
|
(0, chai_1.expect)(result.isValid).to.equal(true);
|
|
@@ -878,67 +886,80 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
878
886
|
};
|
|
879
887
|
return validate(expectations, Constant, null, true);
|
|
880
888
|
});
|
|
881
|
-
it(
|
|
889
|
+
it("should fail if constant map with context key type that is not a valid value", function () {
|
|
882
890
|
let ConstantNoValue = {
|
|
883
|
-
typeid:
|
|
884
|
-
constants: [
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
+
typeid: "ConstantTest:ConstantNoValue-1.0.0",
|
|
892
|
+
constants: [
|
|
893
|
+
{
|
|
894
|
+
id: "map",
|
|
895
|
+
typeid: "Int32",
|
|
896
|
+
context: "map",
|
|
897
|
+
contextKeyType: "badvalue",
|
|
898
|
+
value: {
|
|
899
|
+
"SimpleTest:ConstantTemplate1-1.0.0": 1,
|
|
900
|
+
"SimpleTest:ConstantTemplate2-1.0.0": -1,
|
|
901
|
+
},
|
|
902
|
+
},
|
|
903
|
+
],
|
|
891
904
|
};
|
|
892
905
|
return validate(function (result) {
|
|
893
906
|
(0, chai_1.expect)(result.isValid).to.equal(false);
|
|
894
907
|
(0, chai_1.expect)(result.errors.length).to.equal(1);
|
|
895
|
-
(0, chai_1.expect)(result.errors[0].message).to.include(
|
|
908
|
+
(0, chai_1.expect)(result.errors[0].message).to.include("should match one of the following: typeid,string");
|
|
896
909
|
return result;
|
|
897
910
|
}, ConstantNoValue, null, true);
|
|
898
911
|
});
|
|
899
|
-
it(
|
|
912
|
+
it("should fail if constant map with context key type typeid has invalid typeids as keys", function () {
|
|
900
913
|
let ConstantMapWithBadKeys = {
|
|
901
|
-
typeid:
|
|
902
|
-
constants: [
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
914
|
+
typeid: "ConstantTest:ConstantMapWithBadKeys-1.0.0",
|
|
915
|
+
constants: [
|
|
916
|
+
{
|
|
917
|
+
id: "map",
|
|
918
|
+
typeid: "Int32",
|
|
919
|
+
context: "map",
|
|
920
|
+
contextKeyType: "typeid",
|
|
921
|
+
value: { NotATypeId: 1, AlsoNotATypeId: -1 },
|
|
922
|
+
},
|
|
923
|
+
],
|
|
909
924
|
};
|
|
910
925
|
let expectations = function (result) {
|
|
911
926
|
(0, chai_1.expect)(result.isValid).to.equal(false);
|
|
912
927
|
(0, chai_1.expect)(result.errors.length).to.equal(2);
|
|
913
|
-
(0, chai_1.expect)(result.errors[0].message).to.include(MSG.KEY_MUST_BE_TYPEID +
|
|
914
|
-
(0, chai_1.expect)(result.errors[1].message).to.include(MSG.KEY_MUST_BE_TYPEID +
|
|
928
|
+
(0, chai_1.expect)(result.errors[0].message).to.include(MSG.KEY_MUST_BE_TYPEID + "NotATypeId");
|
|
929
|
+
(0, chai_1.expect)(result.errors[1].message).to.include(MSG.KEY_MUST_BE_TYPEID + "AlsoNotATypeId");
|
|
915
930
|
return result;
|
|
916
931
|
};
|
|
917
932
|
return validate(expectations, ConstantMapWithBadKeys, null, true);
|
|
918
933
|
});
|
|
919
|
-
it(
|
|
934
|
+
it("should fail if map with context key type typeid is not constant", function () {
|
|
920
935
|
let ConstantMapWithProperty = {
|
|
921
|
-
typeid:
|
|
922
|
-
properties: [
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
936
|
+
typeid: "ConstantTest:Outerprop-1.0.0",
|
|
937
|
+
properties: [
|
|
938
|
+
{
|
|
939
|
+
id: "map",
|
|
940
|
+
typeid: "Int32",
|
|
941
|
+
context: "map",
|
|
942
|
+
contextKeyType: "typeid",
|
|
943
|
+
value: {
|
|
944
|
+
"SimpleTest:ConstantTemplate1-1.0.0": 1,
|
|
945
|
+
"SimpleTest:ConstantTemplate2-1.0.0": -1,
|
|
946
|
+
},
|
|
947
|
+
},
|
|
948
|
+
],
|
|
929
949
|
};
|
|
930
950
|
let expectations = function (result) {
|
|
931
|
-
throw new Error(
|
|
951
|
+
throw new Error("This should not be called");
|
|
932
952
|
};
|
|
933
953
|
let failExpectations = function (error) {
|
|
934
|
-
(0, chai_1.expect)(error.toString()).to.include(
|
|
954
|
+
(0, chai_1.expect)(error.toString()).to.include("SV-013: A map with typeids as keys must be constant");
|
|
935
955
|
};
|
|
936
956
|
return performValidation(false, ConstantMapWithProperty, null, true)
|
|
937
|
-
.then(expectations)
|
|
957
|
+
.then(expectations)
|
|
958
|
+
.catch(failExpectations);
|
|
938
959
|
});
|
|
939
960
|
});
|
|
940
|
-
describe(
|
|
941
|
-
it(
|
|
961
|
+
describe("Async validation", function () {
|
|
962
|
+
it("can perform context validation asynchronously", function (done) {
|
|
942
963
|
let schemaValidator = new schemaValidator_1.SchemaValidator();
|
|
943
964
|
let templateValidator = new templateValidator_1.TemplateValidator({
|
|
944
965
|
inheritsFromAsync: schemaValidator.inheritsFromAsync,
|
|
@@ -946,24 +967,26 @@ const templateValidator_1 = require("../../templateValidator");
|
|
|
946
967
|
});
|
|
947
968
|
// Doesn't inherit from 'NamedProperty'. Will cause an error
|
|
948
969
|
let grandParentSchema = {
|
|
949
|
-
|
|
970
|
+
typeid: "test:grandparentschema-1.0.0",
|
|
950
971
|
};
|
|
951
972
|
let parentSchema = {
|
|
952
|
-
|
|
953
|
-
|
|
973
|
+
typeid: "test:parentschema-1.0.0",
|
|
974
|
+
inherits: ["test:grandparentschema-1.0.0"],
|
|
954
975
|
};
|
|
955
976
|
let childSchema = {
|
|
956
|
-
|
|
957
|
-
properties: [
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
977
|
+
typeid: "test:childchema-1.0.0",
|
|
978
|
+
properties: [
|
|
979
|
+
{
|
|
980
|
+
id: "set",
|
|
981
|
+
typeid: "test:parentschema-1.0.0",
|
|
982
|
+
context: "set",
|
|
983
|
+
},
|
|
984
|
+
],
|
|
962
985
|
};
|
|
963
986
|
schemaValidator.register(grandParentSchema);
|
|
964
987
|
schemaValidator.register(parentSchema);
|
|
965
988
|
templateValidator.validateAsync(childSchema).then(() => {
|
|
966
|
-
done(new Error(
|
|
989
|
+
done(new Error("Should not be valid!"));
|
|
967
990
|
}, (error) => {
|
|
968
991
|
(0, chai_1.expect)(error).to.exist;
|
|
969
992
|
done();
|