Skip to content

Commit

Permalink
Fix for issue rjsf-team#827
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcarreiro committed Aug 27, 2021
1 parent 3971321 commit 7e997eb
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 18 deletions.
1 change: 1 addition & 0 deletions packages/core/src/components/fields/BooleanField.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function BooleanField(props) {
autofocus={autofocus}
rawErrors={rawErrors}
DescriptionField={fields.DescriptionField}
uiSchema={uiSchema}
/>
);
}
Expand Down
73 changes: 55 additions & 18 deletions packages/core/test/uiSchema_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,32 +493,69 @@ describe("uiSchema", () => {
});

describe("ui:title", () => {
it("should render the provided title text", () => {
const schema = {
type: "string",
};
const uiSchema = {
"ui:title": "plop",
};
const UI_SCHEMA_TITLE = "plop";
const uiSchema = {
"ui:title": UI_SCHEMA_TITLE,
};

const { node } = createFormComponent({ schema, uiSchema });
describe("string field", () => {
it("should render the provided title text ", () => {
const schema = {
type: "string",
};

const { node } = createFormComponent({ schema, uiSchema });
expect(node.querySelector("label.control-label").textContent).eql(
UI_SCHEMA_TITLE
);
});
});

expect(node.querySelector("label.control-label").textContent).eql("plop");
describe("boolean field", () => {
it("should render the provided title text: boolean", () => {
const schema = {
type: "boolean",
};

const { node } = createFormComponent({ schema, uiSchema });
expect(node.querySelector(".checkbox label").textContent).eql(
UI_SCHEMA_TITLE
);
});
});
});

describe("ui:description", () => {
it("should render the provided description text", () => {
const schema = {
type: "string",
};
const uiSchema = {
"ui:description": "plop",
};
const UI_SCHEMA_DESCRIPTION = "plop";
const uiSchema = {
"ui:description": UI_SCHEMA_DESCRIPTION,
};

const { node } = createFormComponent({ schema, uiSchema });
describe("string field", () => {
it("should render the provided description text", () => {
const schema = {
type: "string",
};

const { node } = createFormComponent({ schema, uiSchema });

expect(node.querySelector("p.field-description").textContent).eql("plop");
expect(node.querySelector("p.field-description").textContent).eql(
UI_SCHEMA_DESCRIPTION
);
});
});

describe("boolean field", () => {
it("should render the provided description text", () => {
const schema = {
type: "boolean",
};

const { node } = createFormComponent({ schema, uiSchema });
expect(node.querySelector("p.field-description").textContent).eql(
UI_SCHEMA_DESCRIPTION
);
});
});
});

Expand Down

0 comments on commit 7e997eb

Please sign in to comment.