forked from Open-EO/openeo-processes
-
Notifications
You must be signed in to change notification settings - Fork 4
/
subtypes-file.test.js
29 lines (24 loc) · 1021 Bytes
/
subtypes-file.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs');
const $RefParser = require("@apidevtools/json-schema-ref-parser");
const { checkJsonSchema, getAjv, isObject, normalizeString } = require('./testHelpers');
test("File subtype-schemas.json", async () => {
let schema;
let fileContent;
try {
fileContent = fs.readFileSync('../meta/subtype-schemas.json');
schema = JSON.parse(fileContent);
} catch(err) {
console.error("The file for subtypes is invalid and can't be read:");
console.error(err);
expect(err).toBeUndefined();
}
expect(isObject(schema)).toBeTruthy();
expect(isObject(schema.definitions)).toBeTruthy();
// lint: Check whether the file is correctly JSON formatted
expect(normalizeString(JSON.stringify(schema, null, 4))).toEqual(normalizeString(fileContent.toString()));
// Is JSON Schema valid?
checkJsonSchema(await getAjv(), schema);
// is everything dereferencable?
let subtypes = await $RefParser.dereference(schema, { dereference: { circular: "ignore" } });
expect(isObject(subtypes)).toBeTruthy();
});