Files
react-jsonschema-form/test/allOf_test.js
Ashwin Ramaswami 4524376deb Add allOf support (#1380)
* feat: add allOf support

* use patch version of json-schema-merge-allof

* fix: publicPath for netlify builds

* fix typo

* fix: pass around shouldMergeAllOf a bit

* fix: remove shouldMergeAllOf

* fix: resolve allOf when calculating idSchema and pathSchema

* Revert "Fix dependency defaults for uncontrolled components (#1371)"

This reverts commit 6728977b00.

* Revert "Revert "Fix dependency defaults for uncontrolled components (#1371)""

This reverts commit ad2bd6841b9218622a2a4bc92a07f4e8b88ce636.

* test: start writing some basic tests

* add doc on allOf

* add allOf playground sample

* handle merging errors by removing allOf

* add test for nested allOf's

* clarify that allOf keyword is dropped

* don't use merge allof fork

* remove change to package-lock.json

* prettier format
2019-12-06 22:29:27 -08:00

50 lines
1.0 KiB
JavaScript

import { expect } from "chai";
import { createFormComponent, createSandbox } from "./test_utils";
describe("allOf", () => {
let sandbox;
beforeEach(() => {
sandbox = createSandbox();
});
afterEach(() => {
sandbox.restore();
});
it("should render a regular input element with a single type, when multiple types specified", () => {
const schema = {
type: "object",
properties: {
foo: {
allOf: [{ type: ["string", "number", "null"] }, { type: "string" }],
},
},
};
const { node } = createFormComponent({
schema,
});
expect(node.querySelectorAll("input")).to.have.length.of(1);
});
it("should be able to handle incompatible types and not crash", () => {
const schema = {
type: "object",
properties: {
foo: {
allOf: [{ type: "string" }, { type: "boolean" }],
},
},
};
const { node } = createFormComponent({
schema,
});
expect(node.querySelectorAll("input")).to.have.length.of(0);
});
});