@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
@@ -1,128 +0,0 @@
1
- const { validateVerifiedClaims } = require("../../../index.js");
2
-
3
- const exampleVouch = require("../../examples/v1/exampleVouch.json");
4
- const exampleDocumentedVouch = require("../../examples/v1/exampleDocumentedVouch.json");
5
- const v2SchemaId =
6
- "https://trust.propdata.org.uk/schemas/v2/pdtf-transaction.json";
7
-
8
- test("returns an empty array for a valid claim", () => {
9
- expect(validateVerifiedClaims([exampleVouch])).toEqual([]);
10
- });
11
-
12
- test("returns an empty array for a valid array of claims", () => {
13
- const claimsArray = [exampleVouch, exampleDocumentedVouch];
14
- expect(validateVerifiedClaims(claimsArray)).toEqual([]);
15
- });
16
-
17
- test("returns an array with an error stating if path is incorrect", () => {
18
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
19
- const originalPath = Object.keys(clonedVouch.claims)[0];
20
- const data = clonedVouch.claims[originalPath];
21
- clonedVouch.claims = {
22
- "/propertyPack/INVALID/materialFacts/councilTax": data,
23
- };
24
- // v2 schema, no overlay
25
- expect(validateVerifiedClaims([clonedVouch], v2SchemaId, null)).toEqual([
26
- "Path /propertyPack/INVALID/materialFacts/councilTax is not a valid PDTF schema path",
27
- ]);
28
- });
29
-
30
- test("returns errors if BASPI requirements are not met and BASPI overlay is specified (default)", () => {
31
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
32
- clonedVouch.claims = {
33
- "/propertyPack/materialFacts/delayFactors": {
34
- hasDelayFactors: { yesNo: "Yes" },
35
- },
36
- };
37
- const errors = validateVerifiedClaims([clonedVouch], v2SchemaId);
38
- expect(errors).toEqual([
39
- {
40
- instancePath: "/hasDelayFactors",
41
- schemaPath: "#/properties/hasDelayFactors/oneOf/1/required",
42
- keyword: "required",
43
- params: { missingProperty: "details" },
44
- message: "must have required property 'details'",
45
- },
46
- {
47
- instancePath: "/hasDelayFactors",
48
- schemaPath: "#/properties/hasDelayFactors/oneOf/1/required",
49
- keyword: "required",
50
- params: { missingProperty: "attachments" },
51
- message: "must have required property 'attachments'",
52
- },
53
- ]);
54
- });
55
-
56
- test("returns no errors if BASPI requirements are not met and null overlay is specified", () => {
57
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
58
- clonedVouch.claims = {
59
- "/propertyPack/materialFacts/delayFactors": {
60
- hasDelayFactors: { yesNo: "Yes" },
61
- },
62
- };
63
- const errors = validateVerifiedClaims([clonedVouch], v2SchemaId, null);
64
- expect(errors).toEqual([]);
65
- });
66
-
67
- test("returns errors for invalid fields even if null overlay is specified", () => {
68
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
69
- clonedVouch.claims = {
70
- "/propertyPack/materialFacts/delayFactors": {
71
- hasDelayFactors: { yesNo: "Maybe" },
72
- },
73
- };
74
- const errors = validateVerifiedClaims([clonedVouch], v2SchemaId, null);
75
- expect(errors).toHaveLength(4);
76
- });
77
-
78
- test("returns an array of errors for verified claim with multiple paths", () => {
79
- const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
80
- clonedVouch.claims = {
81
- "/propertyPack/materialFacts/cousncilTaxBad": {
82
- councilTaxBand: "D",
83
- councilTaxAffectingAlterations: {
84
- yesNo: "Yes",
85
- details:
86
- "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
87
- },
88
- },
89
- "/propertyPack/materialFacts/councilTaxBadTwo": {
90
- councilTaxBand: "D",
91
- councilTaxAffectingAlterations: {
92
- yesNo: "Yes",
93
- details:
94
- "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
95
- },
96
- },
97
- };
98
- expect(validateVerifiedClaims([clonedVouch], v2SchemaId, null)).toEqual([
99
- "Path /propertyPack/materialFacts/cousncilTaxBad is not a valid PDTF schema path",
100
- "Path /propertyPack/materialFacts/councilTaxBadTwo is not a valid PDTF schema path",
101
- ]);
102
- });
103
-
104
- test("returns an empty array of errors for verified claim with multiple valid paths", () => {
105
- const clonedVouch = JSON.parse(
106
- JSON.stringify(exampleVouch),
107
- v2SchemaId,
108
- null
109
- );
110
- clonedVouch.claims = {
111
- "/propertyPack/materialFacts/councilTax": {
112
- councilTaxBand: "D",
113
- councilTaxAffectingAlterations: {
114
- yesNo: "Yes",
115
- details:
116
- "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated",
117
- },
118
- },
119
- "/propertyPack/materialFacts/address": {
120
- line1: "property.line1",
121
- line2: "property.line2",
122
- town: "property.city",
123
- county: "property.province",
124
- postcode: "property.postcode",
125
- },
126
- };
127
- expect(validateVerifiedClaims([clonedVouch], v2SchemaId, null)).toEqual([]);
128
- });