Skip to content

Commit 573cf70

Browse files
committed
test: Require processing:* properties on summaries
1 parent 3b03e5c commit 573cf70

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/template_collection.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ import { AjvOptions, rootDirectory, schemaPath } from './validation.js';
66

77
const examplePath = join(rootDirectory, 'examples/collection.json');
88

9+
const propertyNames = [
10+
'processing:expression',
11+
'processing:facility',
12+
'processing:level',
13+
'processing:lineage',
14+
'processing:software',
15+
];
16+
17+
918
o.spec('Collection', () => {
1019
let validate;
1120
const ajv = new Ajv(AjvOptions);
@@ -44,4 +53,27 @@ o.spec('Collection', () => {
4453
),
4554
).equals(true)(JSON.stringify(validate.errors));
4655
});
56+
57+
o("Example without any summaries processing: properties should fail validation", async () => {
58+
// given
59+
const example = JSON.parse(await fs.readFile(examplePath));
60+
for (const propertyName of propertyNames) {
61+
delete example['summaries'][propertyName];
62+
}
63+
64+
// when
65+
let valid = validate(example);
66+
67+
// then
68+
o(valid).equals(false);
69+
for (const propertyName of propertyNames) {
70+
o(
71+
validate.errors.some(
72+
(error) =>
73+
error.instancePath === "/summaries" &&
74+
error.message === `must have required property '${propertyName}'`,
75+
),
76+
).equals(true)(JSON.stringify(validate.errors));
77+
}
78+
});
4779
});

0 commit comments

Comments
 (0)