@@ -86,6 +86,54 @@ describe("<JsonSchemaForm/>", function(){
8686 expect ( wrapper . find ( "select option" ) . eq ( 2 ) . text ( ) ) . toEqual ( "false" )
8787 } )
8888
89+
90+ it ( "should render the correct options for an enum boolean parameter" , function ( ) {
91+
92+ let props = {
93+ getComponent : getComponentStub ,
94+ value : "" ,
95+ onChange : ( ) => { } ,
96+ keyName : "" ,
97+ fn : { } ,
98+ schema : {
99+ type : "boolean" ,
100+ enum : [ "true" ]
101+ }
102+ }
103+
104+ let wrapper = render ( < JsonSchemaForm { ...props } /> )
105+
106+ expect ( wrapper . find ( "select" ) . length ) . toEqual ( 1 )
107+ expect ( wrapper . find ( "select option" ) . length ) . toEqual ( 2 )
108+ expect ( wrapper . find ( "select option" ) . eq ( 0 ) . text ( ) ) . toEqual ( "--" )
109+ expect ( wrapper . find ( "select option" ) . eq ( 1 ) . text ( ) ) . toEqual ( "true" )
110+ expect ( wrapper . find ( "select option:checked" ) . first ( ) . text ( ) ) . toEqual ( "--" )
111+ } )
112+
113+ it ( "should render the correct options for a required boolean parameter" , function ( ) {
114+
115+ let props = {
116+ getComponent : getComponentStub ,
117+ value : "" ,
118+ onChange : ( ) => { } ,
119+ keyName : "" ,
120+ fn : { } ,
121+ schema : {
122+ type : "boolean" ,
123+ required : true
124+ }
125+ }
126+
127+ let wrapper = render ( < JsonSchemaForm { ...props } /> )
128+
129+ expect ( wrapper . find ( "select" ) . length ) . toEqual ( 1 )
130+ expect ( wrapper . find ( "select option" ) . length ) . toEqual ( 3 )
131+ expect ( wrapper . find ( "select option" ) . eq ( 0 ) . text ( ) ) . toEqual ( "--" )
132+ expect ( wrapper . find ( "select option" ) . eq ( 1 ) . text ( ) ) . toEqual ( "true" )
133+ expect ( wrapper . find ( "select option" ) . eq ( 2 ) . text ( ) ) . toEqual ( "false" )
134+ expect ( wrapper . find ( "select option:checked" ) . first ( ) . text ( ) ) . toEqual ( "--" )
135+ } )
136+
89137 it ( "should render the correct options for a required enum boolean parameter" , function ( ) {
90138
91139 let props = {
@@ -105,7 +153,8 @@ describe("<JsonSchemaForm/>", function(){
105153
106154 expect ( wrapper . find ( "select" ) . length ) . toEqual ( 1 )
107155 expect ( wrapper . find ( "select option" ) . length ) . toEqual ( 1 )
108- expect ( wrapper . find ( "select option" ) . first ( ) . text ( ) ) . toEqual ( "true" )
156+ expect ( wrapper . find ( "select option" ) . eq ( 0 ) . text ( ) ) . toEqual ( "true" )
157+ expect ( wrapper . find ( "select option:checked" ) . first ( ) . text ( ) ) . toEqual ( "true" )
109158 } )
110159 } )
111160 describe ( "objects" , function ( ) {
0 commit comments