api
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
import React from "react"
|
||||
import { render } from "enzyme"
|
||||
import Markdown from "components/providers/markdown"
|
||||
|
||||
describe("UI-3199: Sanitized Markdown causing code examples to be double escaped", function(){
|
||||
it("should single-escape quotes", function(){
|
||||
|
||||
let str = "" +
|
||||
"This is a test: \n\n" +
|
||||
" {\"abc\": \"def\"}\n"
|
||||
|
||||
let props = {
|
||||
source: str
|
||||
}
|
||||
|
||||
let el = render(<Markdown {...props}/>)
|
||||
|
||||
expect(el.find("code").first().text()).toEqual("{\"abc\": \"def\"}\n")
|
||||
expect(el.find("code").first().html()).toEqual("{\"abc\": \"def\"}\n")
|
||||
})
|
||||
})
|
@ -0,0 +1,35 @@
|
||||
import React from "react"
|
||||
import { render } from "enzyme"
|
||||
import Markdown from "components/providers/markdown"
|
||||
|
||||
describe("UI-3279: Empty Markdown inputs causing bare `undefined` in output", function(){
|
||||
it("should return no text for `null` as source input", function(){
|
||||
let props = {
|
||||
source: null
|
||||
}
|
||||
|
||||
let el = render(<Markdown {...props}/>)
|
||||
|
||||
expect(el.text()).toEqual("")
|
||||
})
|
||||
|
||||
it("should return no text for `undefined` as source input", function(){
|
||||
let props = {
|
||||
source: undefined
|
||||
}
|
||||
|
||||
let el = render(<Markdown {...props}/>)
|
||||
|
||||
expect(el.text()).toEqual("")
|
||||
})
|
||||
|
||||
it("should return no text for empty string as source input", function(){
|
||||
let props = {
|
||||
source: ""
|
||||
}
|
||||
|
||||
let el = render(<Markdown {...props}/>)
|
||||
|
||||
expect(el.text()).toEqual("")
|
||||
})
|
||||
})
|
@ -0,0 +1,78 @@
|
||||
|
||||
import React from "react"
|
||||
import { List, fromJS } from "immutable"
|
||||
|
||||
import { render } from "enzyme"
|
||||
import ParameterRow from "components/parameter-row"
|
||||
|
||||
describe("bug #4557: default parameter values", function(){
|
||||
it("should apply a Swagger 2.0 default value", function(){
|
||||
|
||||
const paramValue = fromJS({
|
||||
description: "a pet",
|
||||
type: "string",
|
||||
default: "MyDefaultValue"
|
||||
})
|
||||
|
||||
let props = {
|
||||
getComponent: ()=> "div",
|
||||
specSelectors: {
|
||||
security(){},
|
||||
parameterWithMetaByIdentity(){ return paramValue },
|
||||
isOAS3(){ return false },
|
||||
isSwagger2(){ return true }
|
||||
},
|
||||
fn: {},
|
||||
operation: {get: ()=>{}},
|
||||
onChange: jest.fn(),
|
||||
param: paramValue,
|
||||
rawParam: paramValue,
|
||||
onChangeConsumes: () => {},
|
||||
pathMethod: [],
|
||||
getConfigs: () => { return {} },
|
||||
specPath: List([])
|
||||
}
|
||||
|
||||
render(<ParameterRow {...props}/>)
|
||||
|
||||
expect(props.onChange).toHaveBeenCalled()
|
||||
expect(props.onChange).toHaveBeenCalledWith(paramValue, "MyDefaultValue", false)
|
||||
})
|
||||
it("should apply an OpenAPI 3.0 default value", function(){
|
||||
|
||||
const paramValue = fromJS({
|
||||
description: "a pet",
|
||||
schema: {
|
||||
type: "string",
|
||||
default: "MyDefaultValue"
|
||||
}
|
||||
})
|
||||
|
||||
let props = {
|
||||
getComponent: ()=> "div",
|
||||
specSelectors: {
|
||||
security(){},
|
||||
parameterWithMetaByIdentity(){ return paramValue },
|
||||
isOAS3(){ return true },
|
||||
isSwagger2() { return false }
|
||||
},
|
||||
oas3Selectors: {
|
||||
activeExamplesMember: () => null
|
||||
},
|
||||
fn: {},
|
||||
operation: {get: ()=>{}},
|
||||
onChange: jest.fn(),
|
||||
param: paramValue,
|
||||
rawParam: paramValue,
|
||||
onChangeConsumes: () => {},
|
||||
pathMethod: [],
|
||||
getConfigs: () => { return {} },
|
||||
specPath: List([])
|
||||
}
|
||||
|
||||
render(<ParameterRow {...props}/>)
|
||||
|
||||
expect(props.onChange).toHaveBeenCalled()
|
||||
expect(props.onChange).toHaveBeenCalledWith(paramValue, "MyDefaultValue", false)
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user