File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 1+ import { shallow } from 'enzyme' ;
2+ import 'jest-enzyme' ;
3+ import * as React from 'react' ;
4+ import { SchemaNodeWithMeta } from '../../types' ;
5+ import { Property , Types } from '../shared' ;
6+
7+ describe ( 'Property component' , ( ) => {
8+ it ( 'should render Types with propper type and subtype' , ( ) => {
9+ const node : SchemaNodeWithMeta = {
10+ id : '1' ,
11+ type : 'array' ,
12+ items : {
13+ type : 'string' ,
14+ } ,
15+ annotations : {
16+ examples : { } ,
17+ } ,
18+ validations : { } ,
19+ path : [ ] ,
20+ } ;
21+
22+ const wrapper = shallow ( < Property node = { node } /> ) ;
23+ expect ( wrapper . find ( Types ) ) . toExist ( ) ;
24+ expect ( wrapper . find ( Types ) ) . toHaveProp ( 'type' , 'array' ) ;
25+ expect ( wrapper . find ( Types ) ) . toHaveProp ( 'subtype' , 'string' ) ;
26+ } ) ;
27+ } ) ;
Original file line number Diff line number Diff line change 11import { JSONSchema4 , JSONSchema4TypeName } from 'json-schema' ;
22import { SchemaKind } from '../types' ;
33
4- export function inferType ( node : JSONSchema4 ) : JSONSchema4TypeName | undefined {
4+ export function inferType ( node : JSONSchema4 ) : JSONSchema4TypeName | JSONSchema4TypeName [ ] | undefined {
5+ if ( 'type' in node ) {
6+ return node . type ;
7+ }
8+
59 if ( 'properties' in node ) {
610 return SchemaKind . Object ;
711 }
You can’t perform that action at this time.
0 commit comments