* allow param update by identity + hashed value storage * add specActions.changeParamByIdentity * add identity-based lookup support in spec selectors * migrate `changeParam` usage to `changeParamByIdentity` * migrate usage of `parameterWithMeta` to `parameterWithMetaByIdentity` * update invocations of `changeParamByIdentity` to match fn signature * use OrderedMap throughout hash-based selectors for consistency * normalize usage of ParameterRow `onChange` * migrate bug 4557 tests to reflect new ParameterRow interface * remove exclusive test blocks * linter fixes * copy Parameters changes into OAS3 wrapper * use rawParam for meta lookups in ParameterRow
74 lines
1.9 KiB
JavaScript
74 lines
1.9 KiB
JavaScript
/* eslint-env mocha */
|
|
import React from "react"
|
|
import { List, fromJS } from "immutable"
|
|
import expect, { createSpy } from "expect"
|
|
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 }
|
|
},
|
|
fn: {},
|
|
operation: {get: ()=>{}},
|
|
onChange: createSpy(),
|
|
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 }
|
|
},
|
|
fn: {},
|
|
operation: {get: ()=>{}},
|
|
onChange: createSpy(),
|
|
param: paramValue,
|
|
rawParam: paramValue,
|
|
onChangeConsumes: () => {},
|
|
pathMethod: [],
|
|
getConfigs: () => { return {} },
|
|
specPath: List([])
|
|
}
|
|
|
|
render(<ParameterRow {...props}/>)
|
|
|
|
expect(props.onChange).toHaveBeenCalled()
|
|
expect(props.onChange).toHaveBeenCalledWith(paramValue, "MyDefaultValue", false)
|
|
})
|
|
})
|