@@ -80,6 +80,35 @@ describe('Property component', () => {
8080 } ) ;
8181
8282 describe ( 'properties counter' , ( ) => {
83+ test ( 'given an object among other types, should still display the counter' , ( ) => {
84+ const treeNode : SchemaTreeListNode = {
85+ id : 'foo' ,
86+ name : '' ,
87+ parent : null ,
88+ } ;
89+
90+ const schema : JSONSchema4 = {
91+ type : [ 'string' , 'object' ] ,
92+ properties : {
93+ foo : {
94+ type : 'array' ,
95+ items : {
96+ type : 'integer' ,
97+ } ,
98+ } ,
99+ } ,
100+ } ;
101+
102+ metadataStore . set ( treeNode , {
103+ schemaNode : walk ( schema ) . next ( ) . value . node ,
104+ path : [ ] ,
105+ schema,
106+ } ) ;
107+
108+ const wrapper = shallow ( < Property node = { treeNode } /> ) ;
109+ expect ( wrapper . findWhere ( el => / ^ { \d \} $ / . test ( el . text ( ) ) ) . first ( ) ) . toHaveText ( '{1}' ) ;
110+ } ) ;
111+
83112 it ( 'given missing properties property, should not display the counter' , ( ) => {
84113 const treeNode : SchemaTreeListNode = {
85114 id : 'foo' ,
@@ -98,7 +127,7 @@ describe('Property component', () => {
98127 } ) ;
99128
100129 const wrapper = shallow ( < Property node = { treeNode } /> ) ;
101- expect ( wrapper . findWhere ( el => / ^ \ {\d \} $ / . test ( el . text ( ) ) ) ) . not . toExist ( ) ;
130+ expect ( wrapper . findWhere ( el => / ^ { \d \} $ / . test ( el . text ( ) ) ) ) . not . toExist ( ) ;
102131 } ) ;
103132
104133 it ( 'given nullish properties property, should not display the counter' , ( ) => {
@@ -120,7 +149,7 @@ describe('Property component', () => {
120149 } ) ;
121150
122151 const wrapper = shallow ( < Property node = { treeNode } /> ) ;
123- expect ( wrapper . findWhere ( el => / ^ \ {\d \} $ / . test ( el . text ( ) ) ) ) . not . toExist ( ) ;
152+ expect ( wrapper . findWhere ( el => / ^ { \d \} $ / . test ( el . text ( ) ) ) ) . not . toExist ( ) ;
124153 } ) ;
125154
126155 it ( 'given object properties property, should display the counter' , ( ) => {
@@ -142,7 +171,7 @@ describe('Property component', () => {
142171 } ) ;
143172
144173 const wrapper = shallow ( < Property node = { treeNode } /> ) ;
145- expect ( wrapper . findWhere ( el => / ^ \ {\d \} $ / . test ( el . text ( ) ) ) . first ( ) ) . toHaveText ( '{0}' ) ;
174+ expect ( wrapper . findWhere ( el => / ^ { \d \} $ / . test ( el . text ( ) ) ) . first ( ) ) . toHaveText ( '{0}' ) ;
146175 } ) ;
147176 } ) ;
148177
@@ -170,6 +199,33 @@ describe('Property component', () => {
170199 expect ( wrapper . find ( 'div' ) . first ( ) ) . toHaveText ( 'foo' ) ;
171200 } ) ;
172201
202+ test ( 'given an object among other types, should still display its properties' , ( ) => {
203+ const schema : JSONSchema4 = {
204+ type : [ 'string' , 'object' ] ,
205+ properties : {
206+ foo : {
207+ type : 'array' ,
208+ items : {
209+ type : 'integer' ,
210+ } ,
211+ } ,
212+ } ,
213+ } ;
214+
215+ const tree = new SchemaTree ( schema , new TreeState ( ) , {
216+ expandedDepth : Infinity ,
217+ mergeAllOf : false ,
218+ resolveRef : void 0 ,
219+ shouldResolveEagerly : false ,
220+ onPopulate : void 0 ,
221+ } ) ;
222+
223+ tree . populate ( ) ;
224+
225+ const wrapper = shallow ( < Property node = { tree . itemAt ( 1 ) ! } /> ) ;
226+ expect ( wrapper . find ( 'div' ) . first ( ) ) . toHaveText ( 'foo' ) ;
227+ } ) ;
228+
173229 test ( 'given an array of objects, should display names of those properties' , ( ) => {
174230 const schema : JSONSchema4 = {
175231 type : 'array' ,
0 commit comments