forked from swagger-api/swagger-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4557-default-parameter-values.jsx
75 lines (66 loc) · 1.96 KB
/
4557-default-parameter-values.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* 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 },
isSwagger2(){ 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)
})
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 }
},
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)
})
})