You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

73 lines
1.7 KiB

  1. /* eslint-env mocha */
  2. import expect from "expect"
  3. import { fromJS } from "immutable"
  4. import reducer from "corePlugins/spec/reducers"
  5. describe("spec plugin - reducer", function(){
  6. describe("update operation value", function() {
  7. it("should update the operation at the specified key", () => {
  8. const updateOperationValue = reducer["spec_update_operation_value"]
  9. const state = fromJS({
  10. resolved: {
  11. "paths": {
  12. "/pet": {
  13. "post": {
  14. "description": "my operation"
  15. }
  16. }
  17. }
  18. }
  19. })
  20. let result = updateOperationValue(state, {
  21. payload: {
  22. path: ["/pet", "post"],
  23. value: "application/json",
  24. key: "consumes_value"
  25. }
  26. })
  27. let expectedResult = {
  28. resolved: {
  29. "paths": {
  30. "/pet": {
  31. "post": {
  32. "description": "my operation",
  33. "consumes_value": "application/json"
  34. }
  35. }
  36. }
  37. }
  38. }
  39. expect(result.toJS()).toEqual(expectedResult)
  40. })
  41. it("shouldn't throw an error if we try to update the consumes_value of a null operation", () => {
  42. const updateOperationValue = reducer["spec_update_operation_value"]
  43. const state = fromJS({
  44. resolved: {
  45. "paths": {
  46. "/pet": {
  47. "post": null
  48. }
  49. }
  50. }
  51. })
  52. let result = updateOperationValue(state, {
  53. payload: {
  54. path: ["/pet", "post"],
  55. value: "application/json",
  56. key: "consumes_value"
  57. }
  58. })
  59. expect(result.toJS()).toEqual(state.toJS())
  60. })
  61. })
  62. })