feat: Display minProperties an maxProperties for object schemas (#6272)
This commit is contained in:
@@ -42,7 +42,7 @@ export default class ObjectModel extends Component {
|
|||||||
let title = schema.get("title") || displayName || name
|
let title = schema.get("title") || displayName || name
|
||||||
let requiredProperties = schema.get("required")
|
let requiredProperties = schema.get("required")
|
||||||
let infoProperties = schema
|
let infoProperties = schema
|
||||||
.filter( ( v, key) => ["nullable"].indexOf(key) !== -1 )
|
.filter( ( v, key) => ["maxProperties", "minProperties", "nullable"].indexOf(key) !== -1 )
|
||||||
|
|
||||||
const JumpToPath = getComponent("JumpToPath", true)
|
const JumpToPath = getComponent("JumpToPath", true)
|
||||||
const Markdown = getComponent("Markdown", true)
|
const Markdown = getComponent("Markdown", true)
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ describe("<ObjectModel />", function() {
|
|||||||
...props,
|
...props,
|
||||||
schema: props.schema.set("nullable", true)
|
schema: props.schema.set("nullable", true)
|
||||||
}
|
}
|
||||||
|
const propsMinMaxProperties = {
|
||||||
|
...props,
|
||||||
|
schema: props.schema.set("minProperties", 1).set("maxProperties", 5)
|
||||||
|
}
|
||||||
|
|
||||||
it("renders a collapsible header", function(){
|
it("renders a collapsible header", function(){
|
||||||
const wrapper = shallow(<ObjectModel {...props}/>)
|
const wrapper = shallow(<ObjectModel {...props}/>)
|
||||||
@@ -87,4 +91,20 @@ describe("<ObjectModel />", function() {
|
|||||||
expect(renderProperties.get(0).props.propKey).toEqual("nullable")
|
expect(renderProperties.get(0).props.propKey).toEqual("nullable")
|
||||||
expect(renderProperties.get(0).props.propVal).toEqual(true)
|
expect(renderProperties.get(0).props.propVal).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("doesn't render `minProperties` and `maxProperties` if they are absent", function() {
|
||||||
|
const wrapper = shallow(<ObjectModel {...props}/>)
|
||||||
|
const renderProperties = wrapper.find(Property)
|
||||||
|
expect(renderProperties.length).toEqual(0)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("renders `minProperties` and `maxProperties` if they are defined", function() {
|
||||||
|
const wrapper = shallow(<ObjectModel {...propsMinMaxProperties}/>)
|
||||||
|
const renderProperties = wrapper.find(Property)
|
||||||
|
expect(renderProperties.length).toEqual(2)
|
||||||
|
expect(renderProperties.get(0).props.propKey).toEqual("minProperties")
|
||||||
|
expect(renderProperties.get(0).props.propVal).toEqual(1)
|
||||||
|
expect(renderProperties.get(1).props.propKey).toEqual("maxProperties")
|
||||||
|
expect(renderProperties.get(1).props.propVal).toEqual(5)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user