Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

79 строки
2.0 KiB

  1. /* eslint-env mocha */
  2. import React from "react"
  3. import { List, fromJS } from "immutable"
  4. import expect, { createSpy } from "expect"
  5. import { render } from "enzyme"
  6. import ParameterRow from "components/parameter-row"
  7. describe("bug #4557: default parameter values", function(){
  8. it("should apply a Swagger 2.0 default value", function(){
  9. const paramValue = fromJS({
  10. description: "a pet",
  11. type: "string",
  12. default: "MyDefaultValue"
  13. })
  14. let props = {
  15. getComponent: ()=> "div",
  16. specSelectors: {
  17. security(){},
  18. parameterWithMetaByIdentity(){ return paramValue },
  19. isOAS3(){ return false },
  20. isSwagger2(){ return true }
  21. },
  22. fn: {},
  23. operation: {get: ()=>{}},
  24. onChange: createSpy(),
  25. param: paramValue,
  26. rawParam: paramValue,
  27. onChangeConsumes: () => {},
  28. pathMethod: [],
  29. getConfigs: () => { return {} },
  30. specPath: List([])
  31. }
  32. render(<ParameterRow {...props}/>)
  33. expect(props.onChange).toHaveBeenCalled()
  34. expect(props.onChange).toHaveBeenCalledWith(paramValue, "MyDefaultValue", false)
  35. })
  36. it("should apply an OpenAPI 3.0 default value", function(){
  37. const paramValue = fromJS({
  38. description: "a pet",
  39. schema: {
  40. type: "string",
  41. default: "MyDefaultValue"
  42. }
  43. })
  44. let props = {
  45. getComponent: ()=> "div",
  46. specSelectors: {
  47. security(){},
  48. parameterWithMetaByIdentity(){ return paramValue },
  49. isOAS3(){ return true },
  50. isSwagger2() { return false }
  51. },
  52. oas3Selectors: {
  53. activeExamplesMember: () => null
  54. },
  55. fn: {},
  56. operation: {get: ()=>{}},
  57. onChange: createSpy(),
  58. param: paramValue,
  59. rawParam: paramValue,
  60. onChangeConsumes: () => {},
  61. pathMethod: [],
  62. getConfigs: () => { return {} },
  63. specPath: List([])
  64. }
  65. render(<ParameterRow {...props}/>)
  66. expect(props.onChange).toHaveBeenCalled()
  67. expect(props.onChange).toHaveBeenCalledWith(paramValue, "MyDefaultValue", false)
  68. })
  69. })