forked from rjsf-team/react-jsonschema-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFieldTemplate_test.js
40 lines (33 loc) · 1.07 KB
/
FieldTemplate_test.js
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
33
34
35
36
37
38
39
40
import React from "react";
import { expect } from "chai";
import { createFormComponent, createSandbox } from "./test_utils";
describe("FieldTemplate", () => {
let sandbox;
beforeEach(() => {
sandbox = createSandbox();
});
afterEach(() => {
sandbox.restore();
});
describe("Custom FieldTemplate for disabled property", () => {
function FieldTemplate(props) {
return <div className={props.disabled ? "disabled" : "foo"} />;
}
it("should render with disabled when ui:disabled is truthy", () => {
const { node } = createFormComponent({
schema: { type: "string" },
uiSchema: { "ui:disabled": true },
FieldTemplate,
});
expect(node.querySelectorAll(".disabled")).to.have.length.of(1);
});
it("should render with disabled when ui:disabled is falsey", () => {
const { node } = createFormComponent({
schema: { type: "string" },
uiSchema: { "ui:disabled": false },
FieldTemplate,
});
expect(node.querySelectorAll(".disabled")).to.have.length.of(0);
});
});
});