1+ import React from "react"
2+ import expect from "expect"
3+ import { shallow } from "enzyme"
4+ import { fromJS } from "immutable"
5+ import Response from "components/response"
6+ import ModelExample from "components/model-example"
7+ import { inferSchema } from "corePlugins/samples/fn"
8+
9+ describe ( "<Response />" , function ( ) {
10+ const dummyComponent = ( ) => null
11+ const components = {
12+ headers : dummyComponent ,
13+ highlightCode : dummyComponent ,
14+ modelExample : ModelExample ,
15+ Markdown : dummyComponent ,
16+ operationLink : dummyComponent ,
17+ contentType : dummyComponent
18+ }
19+ const props = {
20+ getComponent : c => components [ c ] ,
21+ specSelectors : {
22+ isOAS3 ( ) {
23+ return false
24+ }
25+ } ,
26+ fn : {
27+ inferSchema
28+ } ,
29+ contentType : "application/json" ,
30+ className : "for-test" ,
31+ response : fromJS ( {
32+ type : "object" ,
33+ properties : {
34+ // Note reverse order: c, b, a
35+ "c" : {
36+ type : "integer"
37+ } ,
38+ "b" : {
39+ type : "boolean"
40+ } ,
41+ "a" : {
42+ type : "string"
43+ }
44+ }
45+ } ) ,
46+ code : "200"
47+ }
48+
49+ it ( "renders the model-example schema properties in order" , function ( ) {
50+ const wrapper = shallow ( < Response { ...props } /> )
51+ const renderedModelExample = wrapper . find ( ModelExample )
52+ expect ( renderedModelExample . length ) . toEqual ( 1 )
53+
54+ // Assert the schema's properties have maintained their order
55+ const modelExampleSchemaProperties = renderedModelExample . props ( ) . schema . toJS ( ) . properties
56+ expect ( Object . keys ( modelExampleSchemaProperties ) ) . toEqual ( [ "c" , "b" , "a" ] )
57+ } )
58+ } )
0 commit comments