data/utils/test.js

26 lines
538 B
JavaScript
Raw Normal View History

2023-11-28 03:05:02 +01:00
import Ajv from "npm:ajv@8.8.2";
import addFormats from "npm:ajv-formats@2.1.1";
import { Engine } from "./engine.js";
const engine = new Engine();
await engine.init();
const ajv = new Ajv({ strict: false });
addFormats(ajv);
2024-02-02 05:23:07 +01:00
function checkCollection(name, schema, data) {
Deno.test(name, () => {
if (!schema) {
return;
}
const validator = ajv.compile(schema);
if (!validator(data)) {
throw validator.errors;
}
});
2023-11-28 03:05:02 +01:00
}
// check index
2024-02-02 05:23:07 +01:00
checkCollection("index", engine.schemas.index, engine.rendered);