-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathallOf.test.ts
32 lines (25 loc) · 1.1 KB
/
allOf.test.ts
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
30
31
32
import { strict as assert } from "assert";
import { compileSchema } from "../compileSchema";
describe("keyword : allOf : get", () => {
it("should step into allOf-property", () => {
const node = compileSchema({
type: "object",
allOf: [{ properties: { header: { type: "string", minLength: 1 } } }]
});
const schema = node.getNodeChild("header", { withHeader: true, header: "huhu" })?.node?.schema;
assert.deepEqual(schema, { type: "string", minLength: 1 });
});
it("should recursively resolve allOf schema", () => {
const node = compileSchema({
type: "object",
allOf: [
{
if: { required: ["withHeader"], properties: { withHeader: { const: true } } },
then: { required: ["header"], properties: { header: { type: "string", minLength: 1 } } }
}
]
});
const schema = node.getNodeChild("header", { withHeader: true, header: "huhu" })?.node?.schema;
assert.deepEqual(schema, { type: "string", minLength: 1 });
});
});