ソースを参照

feat: Display minProperties an maxProperties for object schemas (#6272)

bubble
Helen Kosova 4年前
committed by GitHub
コミット
fd5a59a3fd
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 4AEE18F83AFDEB23
2個のファイルの変更21行の追加1行の削除
  1. +1
    -1
      src/core/components/object-model.jsx
  2. +20
    -0
      test/mocha/components/object-model.jsx

+ 1
- 1
src/core/components/object-model.jsx ファイルの表示

@@ -42,7 +42,7 @@ export default class ObjectModel extends Component {
let title = schema.get("title") || displayName || name
let requiredProperties = schema.get("required")
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 Markdown = getComponent("Markdown", true)


+ 20
- 0
test/mocha/components/object-model.jsx ファイルの表示

@@ -58,6 +58,10 @@ describe("<ObjectModel />", function() {
...props,
schema: props.schema.set("nullable", true)
}
const propsMinMaxProperties = {
...props,
schema: props.schema.set("minProperties", 1).set("maxProperties", 5)
}

it("renders a collapsible header", function(){
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.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)
})
})

読み込み中…
キャンセル
保存