@pdtf/schemas 3.0.0-2 → 3.0.0-21

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.
Files changed (33) hide show
  1. package/index.js +15 -13
  2. package/package.json +1 -1
  3. package/src/examples/v3/exampleTransaction.json +82 -75
  4. package/src/schemas/v2/overlays/baspi.json +510 -2331
  5. package/src/schemas/v2/overlays/con29DW.json +36 -125
  6. package/src/schemas/v2/overlays/con29R.json +5 -143
  7. package/src/schemas/v2/overlays/fme1.json +48 -233
  8. package/src/schemas/v2/overlays/lpe1.json +75 -367
  9. package/src/schemas/v2/overlays/nts.json +17 -103
  10. package/src/schemas/v2/overlays/piq.json +146 -693
  11. package/src/schemas/v2/overlays/rds.json +50 -316
  12. package/src/schemas/v2/overlays/ta10.json +540 -1755
  13. package/src/schemas/v2/overlays/ta6.json +241 -1193
  14. package/src/schemas/v2/overlays/ta7.json +106 -440
  15. package/src/schemas/v3/combined.json +2434 -2581
  16. package/src/schemas/v3/overlays/baspi.json +1360 -3480
  17. package/src/schemas/v3/overlays/con29DW.json +36 -125
  18. package/src/schemas/v3/overlays/con29R.json +5 -143
  19. package/src/schemas/v3/overlays/fme1.json +53 -233
  20. package/src/schemas/v3/overlays/lpe1.json +85 -367
  21. package/src/schemas/v3/overlays/nts.json +711 -634
  22. package/src/schemas/v3/overlays/piq.json +452 -1190
  23. package/src/schemas/v3/overlays/rds.json +500 -1059
  24. package/src/schemas/v3/overlays/ta10.json +540 -1755
  25. package/src/schemas/v3/overlays/ta6.json +787 -1678
  26. package/src/schemas/v3/overlays/ta7.json +220 -462
  27. package/src/schemas/v3/pdtf-transaction.json +1976 -2286
  28. package/src/schemas/v3/skeleton.json +248 -214
  29. package/src/tests/v3/transactionSchema.test.js +28 -18
  30. package/src/tests/v3/verifiedClaimsValidator.test.js +2 -2
  31. package/src/utils/extractOverlay.js +5 -27
  32. package/src/tests/v2/transactionSchema.test.js +0 -361
  33. package/src/tests/v2/verifiedClaimsValidator.test.js +0 -128
@@ -11,23 +11,24 @@ const {
11
11
  } = require("../../../index.js");
12
12
 
13
13
  const exampleTransaction = require("../../examples/v3/exampleTransaction.json");
14
+
14
15
  const schemaId =
15
16
  "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json";
16
17
  // const validator = getValidator(schemaId);
17
18
  const v3TransactionSchema = getTransactionSchema(schemaId);
18
19
 
19
- test("exports a property pack schema, v3 with baspi overlay by default", () => {
20
- const testSchema = getTransactionSchema();
21
- expect(testSchema.$id).toEqual(
22
- "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json"
23
- );
20
+ test("exports a property pack schema, v3 with no overlay by default", () => {
21
+ const testSchema = getTransactionSchema(schemaId);
22
+ // expect(testSchema.$id).toEqual(
23
+ // "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json"
24
+ // );
24
25
  expect(
25
26
  testSchema.properties.propertyPack.properties.materialFacts.baspiRef
26
- ).toEqual("A");
27
+ ).toEqual(undefined);
27
28
  });
28
29
 
29
30
  test("sample is valid BASPI", () => {
30
- const testSchema = getTransactionSchema();
31
+ const testSchema = getTransactionSchema(schemaId, ["baspiV4"]);
31
32
  expect(
32
33
  testSchema.properties.propertyPack.properties.materialFacts.baspiRef
33
34
  ).toEqual("A");
@@ -49,7 +50,7 @@ test("invalid sample is invalid", () => {
49
50
  JSON.stringify(exampleTransaction)
50
51
  );
51
52
  delete clonedExampleTransaction.propertyPack.materialFacts.notices;
52
- const validator = getValidator(schemaId);
53
+ const validator = getValidator(schemaId, ["baspiV4"]);
53
54
  const isValid = validator(clonedExampleTransaction);
54
55
  expect(isValid).toBe(false);
55
56
  });
@@ -147,7 +148,7 @@ test("correctly gets yet, yet another subschema through a dependency", () => {
147
148
 
148
149
  test("correctly gets yet, yet, yet another subschema through a second item dependency", () => {
149
150
  const subschema = getSubschema(
150
- "/propertyPack/materialFacts/environmentalIssues/flooding/typeOfFlooding"
151
+ "/propertyPack/materialFacts/environmentalIssues/flooding/historicalFlooding/typeOfFlooding"
151
152
  );
152
153
  expect(subschema.type).toBe("array");
153
154
  });
@@ -166,6 +167,15 @@ test("correctly gets yes another subschema but through a non-baspi oneOf structu
166
167
  expect(subschema).toEqual({ type: "string" });
167
168
  });
168
169
 
170
+ test("correctly gets an overlaid enum in a subschema", () => {
171
+ const subschema = getSubschema(
172
+ "/propertyPack/materialFacts/electricity/mainsElectricity/yesNo",
173
+ schemaId,
174
+ ["nts2023"]
175
+ );
176
+ expect(subschema.enum).toEqual(["Yes", "No"]);
177
+ });
178
+
169
179
  test("correctly gets a subschema with multiple overlays", () => {
170
180
  const subschema = getSubschema(
171
181
  "/propertyPack/materialFacts/parking/parkingArrangements",
@@ -194,7 +204,6 @@ test("correctly gets a subschema validator for a TA6 overlay", () => {
194
204
  "ta6ed4",
195
205
  ]);
196
206
  let isValid = validator(data);
197
- // console.log(validator.errors);
198
207
  expect(isValid).toBe(true);
199
208
  });
200
209
 
@@ -267,14 +276,14 @@ test("correctly gets a subschema validator for an NTS overlay", () => {
267
276
  expect(isValid).toBe(true);
268
277
  });
269
278
 
270
- test("correctly gets a subschema validator for an LPE1 overlay", () => {
279
+ test("correctly gets a subschema validator for an TA7 overlay", () => {
271
280
  const path = "/propertyPack";
272
281
  const clonedExampleTransaction = JSON.parse(
273
282
  JSON.stringify(exampleTransaction)
274
283
  );
275
284
  const data = jp.get(clonedExampleTransaction, path);
276
285
  const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
277
- "lpe1ed4",
286
+ "ta7ed3",
278
287
  ]);
279
288
  let isValid = validator(data);
280
289
  expect(isValid).toBe(false);
@@ -299,48 +308,49 @@ test("correctly gets titles across schemas, arrays and non-existient title prope
299
308
  "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/ownershipType"
300
309
  )
301
310
  ).toBe("What type of ownership is the property?");
311
+
302
312
  expect(
303
313
  getTitleAtPath(
304
314
  v3TransactionSchema,
305
315
  "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears"
306
316
  )
307
317
  ).toBe("Length of lease (years)");
308
- expect(
309
- getTitleAtPath(
310
- v3TransactionSchema,
311
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/serviceCharge/annualServiceCharge"
312
- )
313
- ).toBe("Amount of current annual service charge (£)");
318
+
314
319
  expect(
315
320
  getTitleAtPath(
316
321
  v3TransactionSchema,
317
322
  "/propertyPack/materialFacts/invalidPath"
318
323
  )
319
324
  ).toBe(undefined);
325
+
320
326
  expect(
321
327
  getTitleAtPath(
322
328
  v3TransactionSchema,
323
329
  "/propertyPack/titlesToBeSold/0/registerExtract"
324
330
  )
325
331
  ).toBe("HMLR Official Copy Register Extract");
332
+
326
333
  expect(
327
334
  getTitleAtPath(
328
335
  v3TransactionSchema,
329
336
  "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/PropertyAddress"
330
337
  )
331
338
  ).toBe("Property address");
339
+
332
340
  expect(
333
341
  getTitleAtPath(
334
342
  v3TransactionSchema,
335
343
  "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/InvalidProp"
336
344
  )
337
345
  ).toBe(undefined);
346
+
338
347
  expect(
339
348
  getTitleAtPath(
340
349
  v3TransactionSchema,
341
350
  "/propertyPack/materialFacts/energyEfficiency/certificate/currentEnergyRating"
342
351
  )
343
352
  ).toBe("Current energy efficiency rating");
353
+
344
354
  expect(
345
355
  getTitleAtPath(
346
356
  v3TransactionSchema,
@@ -27,14 +27,14 @@ test("returns an array with an error stating if path is incorrect", () => {
27
27
  ]);
28
28
  });
29
29
 
30
- test("returns errors if BASPI requirements are not met and BASPI overlay is specified (default)", () => {
30
+ test("returns errors if BASPI requirements are not met and BASPI overlay is specified", () => {
31
31
  const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
32
32
  clonedVouch.claims = {
33
33
  "/propertyPack/materialFacts/delayFactors": {
34
34
  hasDelayFactors: { yesNo: "Yes" },
35
35
  },
36
36
  };
37
- const errors = validateVerifiedClaims([clonedVouch], v3SchemaId);
37
+ const errors = validateVerifiedClaims([clonedVouch], v3SchemaId, ["baspiV4"]);
38
38
  expect(errors).toEqual([
39
39
  {
40
40
  instancePath: "/hasDelayFactors",
@@ -23,30 +23,15 @@ const extractFields = [
23
23
  ];
24
24
 
25
25
  const overlayIncludeProperties = [
26
- "title",
27
- "description",
28
- "enum",
26
+ // "title",
27
+ // "description",
28
+ // "enum",
29
29
  "discriminator",
30
- "minItems",
30
+ // "minItems",
31
31
  ];
32
32
 
33
- const combineMerge = (target, source, options) => {
34
- const destination = target.slice();
35
- source.forEach((item, index) => {
36
- if (typeof destination[index] === "undefined") {
37
- destination[index] = options.cloneUnlessOtherwiseSpecified(item, options);
38
- } else if (options.isMergeableObject(item)) {
39
- destination[index] = merge(target[index], item, options);
40
- } else if (target.indexOf(item) === -1) {
41
- destination.push(item);
42
- }
43
- });
44
- return destination;
45
- };
46
-
47
33
  const flattenSkeleton = (schema) => {
48
34
  if (!schema) return undefined;
49
- // console.log(schema.properties);
50
35
  let returnStructure = {};
51
36
  if (schema.properties) {
52
37
  Object.keys(schema.properties).forEach((key) => {
@@ -55,10 +40,8 @@ const flattenSkeleton = (schema) => {
55
40
  }
56
41
  if (schema.oneOf) {
57
42
  schema.oneOf.forEach((aOneOf) => {
58
- // console.log(aOneOf);
59
43
  if (aOneOf.properties) {
60
44
  Object.entries(aOneOf.properties).forEach(([key, value]) => {
61
- // console.log(aProperty);
62
45
  returnStructure[key] = flattenSkeleton(value);
63
46
  });
64
47
  }
@@ -153,12 +136,7 @@ const deleteProperties = (sourceSchema, propertyNames) => {
153
136
  const overlays = {};
154
137
 
155
138
  extractFields.forEach((key) => {
156
- let overlay = extractOverlay(combinedSchema, key, [
157
- "title",
158
- "description",
159
- "enum",
160
- "discriminator",
161
- ]);
139
+ let overlay = extractOverlay(combinedSchema, key);
162
140
  overlays[key] = overlay;
163
141
  const fileName = `../schemas/v3/overlays/${key}.json`;
164
142
  fs.writeFileSync(fileName, JSON.stringify(overlay, null, 2));
@@ -1,361 +0,0 @@
1
- const jp = require("jsonpointer");
2
- const fs = require("fs");
3
-
4
- const {
5
- getTransactionSchema,
6
- getSubschema,
7
- isPathValid,
8
- getValidator,
9
- getSubschemaValidator,
10
- getTitleAtPath,
11
- } = require("../../../index.js");
12
-
13
- const exampleTransaction = require("../../examples/v2/exampleTransaction.json");
14
- const schemaId =
15
- "https://trust.propdata.org.uk/schemas/v2/pdtf-transaction.json";
16
- // const validator = getValidator(schemaId);
17
- const v2TransactionSchema = getTransactionSchema(schemaId);
18
-
19
- test("exports a property pack schema, v2 with baspi overlay by default", () => {
20
- const testSchema = getTransactionSchema(schemaId);
21
- expect(testSchema.$id).toEqual(
22
- "https://trust.propdata.org.uk/schemas/v2/pdtf-transaction.json"
23
- );
24
- expect(
25
- testSchema.properties.propertyPack.properties.materialFacts.baspiRef
26
- ).toEqual("A");
27
- });
28
-
29
- test("sample is valid BASPI", () => {
30
- const testSchema = getTransactionSchema(schemaId);
31
- expect(
32
- testSchema.properties.propertyPack.properties.materialFacts.properties
33
- .centralHeating.title
34
- ).toEqual("Central Heating");
35
- const validator = getValidator(schemaId);
36
- const isValid = validator(exampleTransaction);
37
- if (!isValid) console.log(validator.errors);
38
- expect(isValid).toBe(true);
39
- });
40
-
41
- test("invalid sample is invalid", () => {
42
- const clonedExampleTransaction = JSON.parse(
43
- JSON.stringify(exampleTransaction)
44
- );
45
- delete clonedExampleTransaction.propertyPack.materialFacts.notices;
46
- const validator = getValidator(schemaId);
47
- const isValid = validator(clonedExampleTransaction);
48
- expect(isValid).toBe(false);
49
- });
50
-
51
- test("sample with missing dependent required fields is invalid", () => {
52
- const clonedExampleTransaction = JSON.parse(
53
- JSON.stringify(exampleTransaction)
54
- );
55
- clonedExampleTransaction.propertyPack.materialFacts.ownership.ownershipsToBeTransferred[0].ownershipType =
56
- "leasehold";
57
- const validator = getValidator(schemaId);
58
- const isValid = validator(clonedExampleTransaction);
59
- expect(isValid).toBe(false);
60
- });
61
-
62
- test("correctly gets a top level subschema", () => {
63
- const subschema = getSubschema("/propertyPack", schemaId);
64
- expect(subschema.title).toBe("Property Pack");
65
- });
66
-
67
- test("correctly identifies a valid path", () => {
68
- const isValid = isPathValid("/propertyPack/materialFacts", schemaId);
69
- expect(isValid).toBe(true);
70
- });
71
-
72
- test("correctly identifies an undefined invalid path", () => {
73
- const isValid = isPathValid("/propertyPack/materialItems", schemaId);
74
- expect(isValid).toBe(false);
75
- });
76
-
77
- test("correctly identifies an error generating invalid path", () => {
78
- const isValid = isPathValid(
79
- "/propertyPack/materialItems/someProperty/item",
80
- schemaId
81
- );
82
- expect(isValid).toBe(false);
83
- });
84
-
85
- test("correctly identifies an array invalid path", () => {
86
- const isValid = isPathValid("/propertyPack/materialFacts/1/item", schemaId);
87
- expect(isValid).toBe(false);
88
- });
89
-
90
- test("correctly gets a subschema", () => {
91
- const subschema = getSubschema(
92
- "/propertyPack/materialFacts/notices",
93
- schemaId
94
- );
95
- expect(subschema.title).toBe("Notices which Affect the Property");
96
- });
97
-
98
- test("correctly gets a subschema through an arrays element", () => {
99
- const subschema = getSubschema(
100
- "/propertyPack/titlesToBeSold/0/registerExtract",
101
- schemaId
102
- );
103
- expect(Object.keys(subschema.properties)).toEqual([
104
- "OCSummaryData",
105
- "OCRegisterData",
106
- ]);
107
- });
108
-
109
- test("correctly gets a subschema through a dependency", () => {
110
- const subschema = getSubschema(
111
- "/propertyPack/materialFacts/delayFactors/hasDelayFactors/details",
112
- schemaId
113
- );
114
- expect(subschema.title).toBe(
115
- "Provide details and likely timescale for delay"
116
- );
117
- });
118
-
119
- test("correctly gets another subschema through a dependency", () => {
120
- const subschema = getSubschema(
121
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears",
122
- schemaId
123
- );
124
- expect(subschema.title).toBe("Length of lease (years)");
125
- });
126
-
127
- test("correctly gets yet another subschema through a dependency", () => {
128
- const subschema = getSubschema(
129
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/groundRent/rentSubjectToIncrease/rentIncreaseCalculated",
130
- schemaId
131
- );
132
- expect(subschema.title).toBe("How is the increase calculated?");
133
- });
134
-
135
- test("correctly gets yet, yet another subschema through a dependency", () => {
136
- const subschema = getSubschema(
137
- "/propertyPack/materialFacts/listingAndConservation/isConservationArea/yesNo",
138
- schemaId
139
- );
140
- expect(subschema.type).toBe("string");
141
- expect(subschema.enum).toStrictEqual(["Yes", "No", "Not known"]);
142
- });
143
-
144
- test("correctly gets yet, yet, yet another subschema through a dependency", () => {
145
- const subschema = getSubschema(
146
- "/propertyPack/materialFacts/environmentalIssues/flooding/typeOfFlooding/other/yesNo",
147
- schemaId
148
- );
149
- expect(subschema.type).toBe("string");
150
- expect(subschema.enum).toStrictEqual(["Yes", "No"]);
151
- });
152
-
153
- test("correctly gets yet, yet, yet another subschema through a second item dependency", () => {
154
- const subschema = getSubschema(
155
- "/propertyPack/materialFacts/environmentalIssues/flooding/typeOfFlooding",
156
- schemaId
157
- );
158
- expect(subschema.type).toBe("object");
159
- });
160
-
161
- test("correctly gets yes another subschema but through a non-baspi oneOf structure", () => {
162
- const subschema = getSubschema(
163
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/RestrictionDetails/RestrictionEntry/ChargeRestriction/EntryDetails/EntryText",
164
- schemaId
165
- );
166
- expect(subschema).toEqual({ type: "string" });
167
- });
168
-
169
- test("correctly gets yes another subschema but through a non-baspi oneOf structure with array option", () => {
170
- const subschema = getSubschema(
171
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/RestrictionDetails/RestrictionEntry/0/ChargeRestriction/EntryDetails/EntryText",
172
- schemaId
173
- );
174
- expect(subschema).toEqual({ type: "string" });
175
- });
176
-
177
- test("correctly gets a subschema with multiple overlays", () => {
178
- const subschema = getSubschema(
179
- "/propertyPack/materialFacts/parking/parkingArrangements",
180
- schemaId,
181
- ["baspiV4", "ta6ed4"]
182
- );
183
- expect(subschema.baspiRef).toBe("A1.6.0");
184
- expect(subschema.ta6Ref).toBe("9.1");
185
- });
186
-
187
- test("correctly gets a subschema validator which is already cached", () => {
188
- const validator = getSubschemaValidator(
189
- "/propertyPack/materialFacts/energyEfficiency/certificate",
190
- schemaId
191
- );
192
- expect(validator).not.toBeNull();
193
- const anotherValidator = getSubschemaValidator(
194
- "/propertyPack/materialFacts/energyEfficiency/certificate",
195
- schemaId
196
- );
197
- expect(anotherValidator).not.toBeNull();
198
- });
199
-
200
- test("correctly gets a subschema validator for a TA6 overlay", () => {
201
- const path = "/propertyPack";
202
- const data = jp.get(exampleTransaction, path);
203
- const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
204
- "ta6ed4",
205
- ]);
206
- let isValid = validator(data);
207
- // console.log(validator.errors);
208
- expect(isValid).toBe(true);
209
- });
210
-
211
- test("correctly gets a subschema validator for a TA6 overlay which validates", () => {
212
- const path =
213
- "/propertyPack/additionalLegalInfo/guaranteesWarrantiesAndIndemnityInsurances/subsidenceWork";
214
- const data = { yesNo: "Yes" };
215
- const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
216
- "ta6ed4",
217
- ]);
218
- let isValid = validator(data);
219
- expect(isValid).toBe(false);
220
- expect(validator.errors[0].message).toBe(
221
- "must have required property 'attachments'"
222
- );
223
- });
224
-
225
- test("correctly gets a subschema validator for a TA6 overlay which validates with non-TA6 field missing", () => {
226
- const path = "/propertyPack";
227
- const clonedExampleTransaction = JSON.parse(
228
- JSON.stringify(exampleTransaction)
229
- );
230
- const data = jp.get(exampleTransaction, path);
231
- data.materialFacts.uprn = undefined;
232
- const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
233
- "ta6ed4",
234
- ]);
235
- let isValid = validator(data);
236
- expect(isValid).toBe(true);
237
- });
238
-
239
- test("correctly gets a subschema validator for a TA6 overlay which validates with non-TA6 section missing", () => {
240
- const path = "/propertyPack";
241
- const clonedExampleTransaction = JSON.parse(
242
- JSON.stringify(exampleTransaction)
243
- );
244
- const data = jp.get(clonedExampleTransaction, path);
245
- data.additionalLegalInfo.smartHomeSystems = undefined;
246
- const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
247
- "ta6ed4",
248
- ]);
249
- let isValid = validator(data);
250
- // console.log(validator.errors);
251
- expect(isValid).toBe(true);
252
- });
253
-
254
- test("correctly gets a subschema validator for a TA6 overlay which fails to validate with BASPI/TA6 section missing", () => {
255
- const path = "/propertyPack";
256
- const clonedExampleTransaction = JSON.parse(
257
- JSON.stringify(exampleTransaction)
258
- );
259
- const data = jp.get(clonedExampleTransaction, path);
260
- data.materialFacts.waterAndDrainage = {};
261
- const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
262
- "ta6ed4",
263
- ]);
264
- let isValid = validator(data);
265
- expect(isValid).toBe(false);
266
- });
267
-
268
- test("correctly gets a subschema validator for an NTS overlay", () => {
269
- const path = "/propertyPack";
270
- const clonedExampleTransaction = JSON.parse(
271
- JSON.stringify(exampleTransaction)
272
- );
273
- const data = jp.get(clonedExampleTransaction, path);
274
- const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
275
- "nts2023",
276
- ]);
277
- let isValid = validator(data);
278
- expect(isValid).toBe(true);
279
- });
280
-
281
- test("correctly gets a subschema validator for an LPE1 overlay", () => {
282
- const path = "/propertyPack";
283
- const clonedExampleTransaction = JSON.parse(
284
- JSON.stringify(exampleTransaction)
285
- );
286
- const data = jp.get(clonedExampleTransaction, path);
287
- const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
288
- "lpe1ed4",
289
- ]);
290
- let isValid = validator(data);
291
- expect(isValid).toBe(false);
292
- });
293
-
294
- test("correctly gets a subschema validator which validates", () => {
295
- const path = "/propertyPack/materialFacts/notices";
296
- const validator = getSubschemaValidator(path);
297
- const data = jp.get(exampleTransaction, path);
298
- expect(data.neighbourDevelopment.yesNo).toBe("No");
299
- let isValid = validator(data);
300
- expect(isValid).toBe(true);
301
- data.neighbourDevelopment.yesNo = "Invalid string";
302
- isValid = validator(data);
303
- expect(isValid).toBe(false);
304
- });
305
-
306
- test("correctly gets titles across schemas, arrays and non-existient title properties", () => {
307
- expect(
308
- getTitleAtPath(
309
- v2TransactionSchema,
310
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/ownershipType"
311
- )
312
- ).toBe("What type of ownership is the property?");
313
- expect(
314
- getTitleAtPath(
315
- v2TransactionSchema,
316
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears"
317
- )
318
- ).toBe("Length of lease (years)");
319
- expect(
320
- getTitleAtPath(
321
- v2TransactionSchema,
322
- "/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/serviceCharge/annualServiceCharge"
323
- )
324
- ).toBe("Amount of current annual service charge (£)");
325
- expect(
326
- getTitleAtPath(
327
- v2TransactionSchema,
328
- "/propertyPack/materialFacts/invalidPath"
329
- )
330
- ).toBe(undefined);
331
- expect(
332
- getTitleAtPath(
333
- v2TransactionSchema,
334
- "/propertyPack/titlesToBeSold/0/registerExtract"
335
- )
336
- ).toBe("HMLR Official Copy Register Extract");
337
- expect(
338
- getTitleAtPath(
339
- v2TransactionSchema,
340
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/PropertyAddress"
341
- )
342
- ).toBe("Property address");
343
- expect(
344
- getTitleAtPath(
345
- v2TransactionSchema,
346
- "/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/InvalidProp"
347
- )
348
- ).toBe(undefined);
349
- expect(
350
- getTitleAtPath(
351
- v2TransactionSchema,
352
- "/propertyPack/materialFacts/energyEfficiency/certificate/currentEnergyRating"
353
- )
354
- ).toBe("Current energy efficiency rating");
355
- expect(
356
- getTitleAtPath(
357
- v2TransactionSchema,
358
- "/propertyPack/additionalLegalInfo/occupiers/othersAged17OrOver/aged17OrOverNames"
359
- )
360
- ).toBe("Please provide their full names and ages.");
361
- });