14
test/e2e-cypress/static/documents/bugs/5660-model.yaml
Normal file
14
test/e2e-cypress/static/documents/bugs/5660-model.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
openapi: 3.0.2
|
||||
info:
|
||||
title: test
|
||||
description: Nullable model itself
|
||||
version: '1.0'
|
||||
paths: {}
|
||||
components:
|
||||
schemas:
|
||||
SomeObject:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
nullable: true
|
||||
17
test/e2e-cypress/static/documents/bugs/5660-property.yaml
Normal file
17
test/e2e-cypress/static/documents/bugs/5660-property.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
openapi: 3.0.2
|
||||
info:
|
||||
title: test
|
||||
description: Nullable object in model property
|
||||
version: '1.0'
|
||||
paths: {}
|
||||
components:
|
||||
schemas:
|
||||
SomeObject:
|
||||
type: object
|
||||
properties:
|
||||
meta:
|
||||
type: object
|
||||
properties:
|
||||
tag:
|
||||
type: string
|
||||
nullable: true
|
||||
20
test/e2e-cypress/tests/bugs/5660.js
Normal file
20
test/e2e-cypress/tests/bugs/5660.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// http://github.com/swagger-api/swagger-ui/issues/5660
|
||||
|
||||
const expectedValue = "nullable: true"
|
||||
|
||||
describe("#5660: Nullable object", () => {
|
||||
it("should render `nullable` marker for object ifself", () => {
|
||||
cy.visit("/?url=/documents/bugs/5660-model.yaml")
|
||||
.get("#model-SomeObject .model-toggle")
|
||||
.click()
|
||||
.get("#model-SomeObject > .model-box")
|
||||
.contains(expectedValue)
|
||||
})
|
||||
it("should render `nullable` marker for nexted object in property", () => {
|
||||
cy.visit("/?url=/documents/bugs/5660-property.yaml")
|
||||
.get("#model-SomeObject .model-toggle")
|
||||
.click()
|
||||
.get("#model-SomeObject > .model-box")
|
||||
.contains(expectedValue)
|
||||
})
|
||||
})
|
||||
@@ -7,6 +7,7 @@ import ModelExample from "components/model-example"
|
||||
import Immutable from "immutable"
|
||||
import Model from "components/model"
|
||||
import ModelCollapse from "components/model-collapse"
|
||||
import Property from "components/property"
|
||||
import { inferSchema } from "corePlugins/samples/fn"
|
||||
|
||||
describe("<ObjectModel />", function() {
|
||||
@@ -15,7 +16,8 @@ describe("<ObjectModel />", function() {
|
||||
"JumpToPath" : dummyComponent,
|
||||
"Markdown" : dummyComponent,
|
||||
"Model" : Model,
|
||||
"ModelCollapse" : ModelCollapse
|
||||
"ModelCollapse" : ModelCollapse,
|
||||
"Property" : Property
|
||||
}
|
||||
const props = {
|
||||
getComponent: c => components[c],
|
||||
@@ -52,6 +54,11 @@ describe("<ObjectModel />", function() {
|
||||
},
|
||||
className: "for-test"
|
||||
}
|
||||
const propsNullable = {
|
||||
...props,
|
||||
schema: props.schema.set("nullable", true)
|
||||
}
|
||||
|
||||
it("renders a collapsible header", function(){
|
||||
const wrapper = shallow(<ObjectModel {...props}/>)
|
||||
const renderedModelCollapse = wrapper.find(ModelCollapse)
|
||||
@@ -66,4 +73,18 @@ describe("<ObjectModel />", function() {
|
||||
expect(renderedModel.get(1).props.schema.get("name")).toEqual("b")
|
||||
expect(renderedModel.get(2).props.schema.get("name")).toEqual("a")
|
||||
})
|
||||
|
||||
it("doesn't render `nullable` for model when it absent", function() {
|
||||
const wrapper = shallow(<ObjectModel {...props}/>)
|
||||
const renderProperties = wrapper.find(Property)
|
||||
expect(renderProperties.length).toEqual(0)
|
||||
})
|
||||
|
||||
it("renders `nullable` for model", function() {
|
||||
const wrapper = shallow(<ObjectModel {...propsNullable}/>)
|
||||
const renderProperties = wrapper.find(Property)
|
||||
expect(renderProperties.length).toEqual(1)
|
||||
expect(renderProperties.get(0).props.propKey).toEqual("nullable")
|
||||
expect(renderProperties.get(0).props.propVal).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user