forked from rjsf-team/react-jsonschema-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDescriptionField_test.js
56 lines (45 loc) · 1.38 KB
/
DescriptionField_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from "react";
import { expect } from "chai";
import DescriptionField from "../src/components/fields/DescriptionField";
import { createSandbox, createComponent } from "./test_utils";
describe("DescriptionField", () => {
let sandbox;
beforeEach(() => {
sandbox = createSandbox();
});
afterEach(() => {
sandbox.restore();
});
// For some reason, stateless components needs to be wrapped into a stateful
// one to be rendered into the document.
class DescriptionFieldWrapper extends React.Component {
constructor(props) {
super(props);
}
render() {
return <DescriptionField {...this.props} />;
}
}
it("should return a div for a custom component", () => {
const props = {
description: <em>description</em>,
};
const { node } = createComponent(DescriptionFieldWrapper, props);
expect(node.tagName).to.equal("DIV");
});
it("should return a p for a description text", () => {
const props = {
description: "description",
};
const { node } = createComponent(DescriptionFieldWrapper, props);
expect(node.tagName).to.equal("P");
});
it("should have the expected id", () => {
const props = {
description: "Field description",
id: "sample_id",
};
const { node } = createComponent(DescriptionFieldWrapper, props);
expect(node.id).to.equal("sample_id");
});
});