feat: add topology graph v0.2.2 contract
This commit is contained in:
21
tests/schema.test.ts
Normal file
21
tests/schema.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { test } from "node:test";
|
||||
import Ajv from "ajv";
|
||||
import { scanUrl } from "../src/engine.js";
|
||||
|
||||
test("topology graph JSON schema validates emitted scan artifacts", async () => {
|
||||
const schema = JSON.parse(await readFile("schemas/topology-graph.schema.json", "utf8"));
|
||||
const ajv = new Ajv({ allErrors: true });
|
||||
const validate = ajv.compile(schema);
|
||||
const dir = await mkdtemp(path.join(tmpdir(), "action-topology-schema-test-"));
|
||||
try {
|
||||
const graph = await scanUrl({ url: "examples/simple.html", out: path.join(dir, "graph.json") });
|
||||
|
||||
assert.equal(validate(graph), true, JSON.stringify(validate.errors, null, 2));
|
||||
} finally {
|
||||
await rm(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user