Browse Source

Merge branch 'master' into bug/2919-relative-spec-infer-scheme

bubble
shockey 7 years ago
committed by GitHub
parent
commit
754d57396a
3 changed files with 78 additions and 2 deletions
  1. +1
    -1
      .travis.yml
  2. +5
    -1
      src/core/plugins/spec/reducers.js
  3. +72
    -0
      test/core/plugins/spec-reducer.js

+ 1
- 1
.travis.yml View File

@@ -32,7 +32,7 @@ after_success:
docker build -t $DOCKER_IMAGE_NAME .;
if [ ! -z "$TRAVIS_TAG" ]; then
docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
docker push $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG;
docker tag $DOCKER_IMAGE_NAME $DOCKER_IMAGE_NAME:latest;
docker push $DOCKER_IMAGE_NAME:latest;
else


+ 5
- 1
src/core/plugins/spec/reducers.js View File

@@ -97,7 +97,11 @@ export default {
},

[UPDATE_OPERATION_VALUE]: (state, { payload: { path, value, key } }) => {
return state.setIn(["resolved", "paths", ...path, key], fromJS(value))
let operationPath = ["resolved", "paths", ...path]
if(!state.getIn(operationPath)) {
return state
}
return state.setIn([...operationPath, key], fromJS(value))
},

[CLEAR_RESPONSE]: (state, { payload: { path, method } } ) =>{


+ 72
- 0
test/core/plugins/spec-reducer.js View File

@@ -0,0 +1,72 @@
/* eslint-env mocha */
import expect from "expect"
import { fromJS } from "immutable"
import reducer from "corePlugins/spec/reducers"

describe("spec plugin - reducer", function(){

describe("update operation value", function() {
it("should update the operation at the specified key", () => {
const updateOperationValue = reducer["spec_update_operation_value"]

const state = fromJS({
resolved: {
"paths": {
"/pet": {
"post": {
"description": "my operation"
}
}
}
}
})

let result = updateOperationValue(state, {
payload: {
path: ["/pet", "post"],
value: "application/json",
key: "consumes_value"
}
})

let expectedResult = {
resolved: {
"paths": {
"/pet": {
"post": {
"description": "my operation",
"consumes_value": "application/json"
}
}
}
}
}

expect(result.toJS()).toEqual(expectedResult)
})

it("shouldn't throw an error if we try to update the consumes_value of a null operation", () => {
const updateOperationValue = reducer["spec_update_operation_value"]

const state = fromJS({
resolved: {
"paths": {
"/pet": {
"post": null
}
}
}
})

let result = updateOperationValue(state, {
payload: {
path: ["/pet", "post"],
value: "application/json",
key: "consumes_value"
}
})

expect(result.toJS()).toEqual(state.toJS())
})
})
})

Loading…
Cancel
Save