25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

74 satır
1.9 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. },
  21. fn: {},
  22. operation: {get: ()=>{}},
  23. onChange: createSpy(),
  24. param: paramValue,
  25. rawParam: paramValue,
  26. onChangeConsumes: () => {},
  27. pathMethod: [],
  28. getConfigs: () => { return {} },
  29. specPath: List([])
  30. }
  31. render(<ParameterRow {...props}/>)
  32. expect(props.onChange).toHaveBeenCalled()
  33. expect(props.onChange).toHaveBeenCalledWith(paramValue, "MyDefaultValue", false)
  34. })
  35. it("should apply an OpenAPI 3.0 default value", function(){
  36. const paramValue = fromJS({
  37. description: "a pet",
  38. schema: {
  39. type: "string",
  40. default: "MyDefaultValue"
  41. }
  42. })
  43. let props = {
  44. getComponent: ()=> "div",
  45. specSelectors: {
  46. security(){},
  47. parameterWithMetaByIdentity(){ return paramValue },
  48. isOAS3(){ return true }
  49. },
  50. fn: {},
  51. operation: {get: ()=>{}},
  52. onChange: createSpy(),
  53. param: paramValue,
  54. rawParam: paramValue,
  55. onChangeConsumes: () => {},
  56. pathMethod: [],
  57. getConfigs: () => { return {} },
  58. specPath: List([])
  59. }
  60. render(<ParameterRow {...props}/>)
  61. expect(props.onChange).toHaveBeenCalled()
  62. expect(props.onChange).toHaveBeenCalledWith(paramValue, "MyDefaultValue", false)
  63. })
  64. })