Add schema regression tests for shorthand symbol model
This commit is contained in:
parent
925f8072e9
commit
2cfef4198a
34
tests/schema-regression.test.js
Normal file
34
tests/schema-regression.test.js
Normal file
@ -0,0 +1,34 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import schema from "../frontend/schemeta.schema.json" with { type: "json" };
|
||||
|
||||
test("schema keeps streamlined symbol shorthand support", () => {
|
||||
const symbol = schema?.$defs?.symbol;
|
||||
assert.ok(symbol);
|
||||
assert.deepEqual(symbol.required, []);
|
||||
assert.equal(symbol.properties.template_name.type, "string");
|
||||
assert.ok(Array.isArray(symbol.examples));
|
||||
assert.ok(symbol.examples.some((v) => v.template_name === "resistor"));
|
||||
assert.ok(symbol.examples.some((v) => v.category === "generic"));
|
||||
});
|
||||
|
||||
test("schema supports built-in instance.part shortcuts without explicit symbols", () => {
|
||||
const instance = schema?.$defs?.instance;
|
||||
assert.ok(instance);
|
||||
assert.ok(Array.isArray(instance.anyOf));
|
||||
assert.ok(instance.anyOf.some((rule) => Array.isArray(rule.required) && rule.required.includes("symbol")));
|
||||
assert.ok(instance.anyOf.some((rule) => Array.isArray(rule.required) && rule.required.includes("part")));
|
||||
|
||||
const partEnum = instance.properties?.part?.enum ?? [];
|
||||
assert.ok(partEnum.includes("resistor"));
|
||||
assert.ok(partEnum.includes("capacitor"));
|
||||
assert.ok(partEnum.includes("generic"));
|
||||
});
|
||||
|
||||
test("schema preserves per-pin UI edit metadata contract", () => {
|
||||
const pinUi = schema?.$defs?.instance?.properties?.properties?.properties?.pin_ui;
|
||||
assert.ok(pinUi);
|
||||
const pinUiEntry = pinUi.additionalProperties;
|
||||
assert.ok(pinUiEntry);
|
||||
assert.equal(pinUiEntry.properties.show_net_label.type, "boolean");
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user