* Updated docs for correct usage of SWAGGER_JSON * Removed href attribute from anchor tag if deeplinking is disabled * If deeplinking is disabled the anchor tag has no href attribute as a result the mouse pointer is not a pointer as it is no longer a hyperlink, setting the cursor explicitly to pointer. * Refactor: use ternary operators at attribute level instead of element level * Only polyfill Promise if it doesn't exist at all * v3.1.7 * Typo fix * fix #3624 * Squash commit: OAS3 Try-It-Out changes * Parse JSON requestBodies so Client can consume them correctly * Use Client branch * Fix typo in swagger-client dependency * Fix property names being displayed in array models * Working on refactoring of model.jsx * Fit linter and tests * Add comment to array-model for to clarify change. Rework logic in `Model.render()` to fix bug with overriding name and schema from `$ref` definition. * v3.2.0 * fromJS does not maintain order of object properties. Use a reviver function with fromJS inside the response.jsx component for the passed down schema prop. * OAS3 Accept header control: Component-side * OAS3 Accept header control: State-side * Update response.jsx to use already existing, fromJSOrdered function * Added test for response.jsx to make sure properties are passed to `ModelExample` component in the correct order * Remove `it.only` from new test * Fixes #3596 Wrap `isShownKey` values in a function that replaces spaces with underscores. When parsing the hash on route change, replace the spaces in the values with underscores again. * Replace spaces with underscores when setting the hash value and inserting the ID into the DOM. Escape the deep link path when querying for the DOM element on hash change. * Handle null value in createDeepLinkPath * Add extra check for String types in `createDeepLinkPath`. Add `trim()` call on passed-in value in `createDeepLinkPath`. Added unit tests for new deep link util functions. * LINTING! * Roll back win import removal Lost in merge conflict.... * More merge oversights...
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
import React from "react"
|
|
import expect from "expect"
|
|
import { shallow } from "enzyme"
|
|
import { fromJS } from "immutable"
|
|
import Response from "components/response"
|
|
import ModelExample from "components/model-example"
|
|
import { inferSchema } from "corePlugins/samples/fn"
|
|
|
|
describe("<Response />", function() {
|
|
const dummyComponent = () => null
|
|
const components = {
|
|
headers: dummyComponent,
|
|
highlightCode: dummyComponent,
|
|
modelExample: ModelExample,
|
|
Markdown: dummyComponent,
|
|
operationLink: dummyComponent,
|
|
contentType: dummyComponent
|
|
}
|
|
const props = {
|
|
getComponent: c => components[c],
|
|
specSelectors: {
|
|
isOAS3() {
|
|
return false
|
|
}
|
|
},
|
|
fn: {
|
|
inferSchema
|
|
},
|
|
contentType: "application/json",
|
|
className: "for-test",
|
|
response: fromJS({
|
|
type: "object",
|
|
properties: {
|
|
// Note reverse order: c, b, a
|
|
"c": {
|
|
type: "integer"
|
|
},
|
|
"b": {
|
|
type: "boolean"
|
|
},
|
|
"a": {
|
|
type: "string"
|
|
}
|
|
}
|
|
}),
|
|
code: "200"
|
|
}
|
|
|
|
it("renders the model-example schema properties in order", function() {
|
|
const wrapper = shallow(<Response {...props}/>)
|
|
const renderedModelExample = wrapper.find(ModelExample)
|
|
expect(renderedModelExample.length).toEqual(1)
|
|
|
|
// Assert the schema's properties have maintained their order
|
|
const modelExampleSchemaProperties = renderedModelExample.props().schema.toJS().properties
|
|
expect( Object.keys(modelExampleSchemaProperties) ).toEqual(["c", "b", "a"])
|
|
})
|
|
}) |