-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Added ui:*Template properties
#1152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ef36aa4
b577b0f
293038c
8673da0
0c16070
86e9c44
fd4acec
624894f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,14 +46,33 @@ describe("ArrayFieldTemplate", () => { | |
| } | ||
| } | ||
|
|
||
| it("should render a stateful custom component", () => { | ||
| const { node } = createFormComponent({ | ||
| schema: { type: "array", items: { type: "string" } }, | ||
| formData, | ||
| ArrayFieldTemplate, | ||
| describe("with template globally configured", () => { | ||
| it("should render a stateful custom component", () => { | ||
| const { node } = createFormComponent({ | ||
| schema: { type: "array", items: { type: "string" } }, | ||
| formData, | ||
| ArrayFieldTemplate, | ||
| }); | ||
|
|
||
| expect(node.querySelectorAll(".field-array div")).to.have.length.of( | ||
| 6 | ||
| ); | ||
| }); | ||
| }); | ||
| describe("with template configured in ui:ArrayFieldTemplate", () => { | ||
| it("should render a stateful custom component", () => { | ||
| const { node } = createFormComponent({ | ||
| schema: { type: "array", items: { type: "string" } }, | ||
| formData, | ||
| uiSchema: { | ||
| "ui:ArrayFieldTemplate": ArrayFieldTemplate, | ||
| }, | ||
| }); | ||
|
|
||
| expect(node.querySelectorAll(".field-array div")).to.have.length.of( | ||
| 6 | ||
| ); | ||
| }); | ||
|
|
||
| expect(node.querySelectorAll(".field-array div")).to.have.length.of(6); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -65,52 +84,74 @@ describe("ArrayFieldTemplate", () => { | |
| items: { type: "string" }, | ||
| }; | ||
|
|
||
| const uiSchema = { | ||
| classNames: "custom-array", | ||
| }; | ||
|
|
||
| let node; | ||
|
|
||
| beforeEach(() => { | ||
| node = createFormComponent({ | ||
| ArrayFieldTemplate, | ||
| formData, | ||
| schema, | ||
| uiSchema, | ||
| }).node; | ||
| }); | ||
| describe("with template globally configured", () => { | ||
| const uiSchema = { | ||
| classNames: "custom-array", | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| node = createFormComponent({ | ||
| ArrayFieldTemplate, | ||
| formData, | ||
| schema, | ||
| uiSchema, | ||
| }).node; | ||
| }); | ||
|
|
||
| it("should render one root element for the array", () => { | ||
| expect(node.querySelectorAll(".custom-array")).to.have.length.of(1); | ||
| sharedIts(); | ||
| }); | ||
|
|
||
| it("should render one add button", () => { | ||
| expect(node.querySelectorAll(".custom-array-add")).to.have.length.of(1); | ||
| describe("with template configured in ui:ArrayFieldTemplate", () => { | ||
| const uiSchema = { | ||
| classNames: "custom-array", | ||
| "ui:ArrayFieldTemplate": ArrayFieldTemplate, | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| node = createFormComponent({ | ||
| formData, | ||
| schema, | ||
| uiSchema, | ||
| }).node; | ||
| }); | ||
| sharedIts(); | ||
| }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test in which a template is globally configured and a template is configured in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
| function sharedIts() { | ||
| it("should render one root element for the array", () => { | ||
| expect(node.querySelectorAll(".custom-array")).to.have.length.of(1); | ||
| }); | ||
|
|
||
| it("should render one child for each array item", () => { | ||
| expect(node.querySelectorAll(".custom-array-item")).to.have.length.of( | ||
| formData.length | ||
| ); | ||
| }); | ||
| it("should render one add button", () => { | ||
| expect(node.querySelectorAll(".custom-array-add")).to.have.length.of( | ||
| 1 | ||
| ); | ||
| }); | ||
|
|
||
| it("should render text input for each array item", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item .field input[type=text]") | ||
| ).to.have.length.of(formData.length); | ||
| }); | ||
| it("should render one child for each array item", () => { | ||
| expect(node.querySelectorAll(".custom-array-item")).to.have.length.of( | ||
| formData.length | ||
| ); | ||
| }); | ||
|
|
||
| it("should render move up button for all but one array items", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item-move-up") | ||
| ).to.have.length.of(formData.length - 1); | ||
| }); | ||
| it("should render text input for each array item", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item .field input[type=text]") | ||
| ).to.have.length.of(formData.length); | ||
| }); | ||
|
|
||
| it("should render move down button for all but one array items", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item-move-down") | ||
| ).to.have.length.of(formData.length - 1); | ||
| }); | ||
| it("should render move up button for all but one array items", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item-move-up") | ||
| ).to.have.length.of(formData.length - 1); | ||
| }); | ||
|
|
||
| it("should render move down button for all but one array items", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item-move-down") | ||
| ).to.have.length.of(formData.length - 1); | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| describe("fixed items", () => { | ||
|
|
@@ -121,52 +162,72 @@ describe("ArrayFieldTemplate", () => { | |
| items: [{ type: "string" }, { type: "string" }, { type: "string" }], | ||
| }; | ||
|
|
||
| const uiSchema = { | ||
| classNames: "custom-array", | ||
| }; | ||
|
|
||
| let node; | ||
|
|
||
| beforeEach(() => { | ||
| node = createFormComponent({ | ||
| ArrayFieldTemplate, | ||
| formData, | ||
| schema, | ||
| uiSchema, | ||
| }).node; | ||
| describe("with template globally configured", () => { | ||
| const uiSchema = { | ||
| classNames: "custom-array", | ||
| }; | ||
| beforeEach(() => { | ||
| node = createFormComponent({ | ||
| formData, | ||
| schema, | ||
| uiSchema, | ||
| ArrayFieldTemplate, | ||
| }).node; | ||
| }); | ||
| sharedIts(); | ||
| }); | ||
|
|
||
| it("should render one root element for the array", () => { | ||
| expect(node.querySelectorAll(".custom-array")).to.have.length.of(1); | ||
| describe("with template configured in ui:ArrayFieldTemplate", () => { | ||
| const uiSchema = { | ||
| classNames: "custom-array", | ||
| "ui:ArrayFieldTemplate": ArrayFieldTemplate, | ||
| }; | ||
| beforeEach(() => { | ||
| node = createFormComponent({ | ||
| formData, | ||
| schema, | ||
| uiSchema, | ||
| }).node; | ||
| }); | ||
| sharedIts(); | ||
| }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test in which a template is globally configured and a template is configured in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
| function sharedIts() { | ||
| it("should render one root element for the array", () => { | ||
| expect(node.querySelectorAll(".custom-array")).to.have.length.of(1); | ||
| }); | ||
|
|
||
| it("should not render an add button", () => { | ||
| expect(node.querySelectorAll(".custom-array-add")).to.have.length.of(0); | ||
| }); | ||
| it("should not render an add button", () => { | ||
| expect(node.querySelectorAll(".custom-array-add")).to.have.length.of( | ||
| 0 | ||
| ); | ||
| }); | ||
|
|
||
| it("should render one child for each array item", () => { | ||
| expect(node.querySelectorAll(".custom-array-item")).to.have.length.of( | ||
| formData.length | ||
| ); | ||
| }); | ||
| it("should render one child for each array item", () => { | ||
| expect(node.querySelectorAll(".custom-array-item")).to.have.length.of( | ||
| formData.length | ||
| ); | ||
| }); | ||
|
|
||
| it("should render text input for each array item", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item .field input[type=text]") | ||
| ).to.have.length.of(formData.length); | ||
| }); | ||
| it("should render text input for each array item", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item .field input[type=text]") | ||
| ).to.have.length.of(formData.length); | ||
| }); | ||
|
|
||
| it("should not render any move up buttons", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item-move-up") | ||
| ).to.have.length.of(0); | ||
| }); | ||
| it("should not render any move up buttons", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item-move-up") | ||
| ).to.have.length.of(0); | ||
| }); | ||
|
|
||
| it("should not render any move down buttons", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item-move-down") | ||
| ).to.have.length.of(0); | ||
| }); | ||
| it("should not render any move down buttons", () => { | ||
| expect( | ||
| node.querySelectorAll(".custom-array-item-move-down") | ||
| ).to.have.length.of(0); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.