@@ -183,7 +183,7 @@ export class Select extends React.Component { | |||||
{ allowEmptyValue ? <option value="">--</option> : null } | { allowEmptyValue ? <option value="">--</option> : null } | ||||
{ | { | ||||
allowedValues.map(function (item, key) { | allowedValues.map(function (item, key) { | ||||
return <option key={ key } value={ String(item) }>{ item }</option> | |||||
return <option key={ key } value={ String(item) }>{ String(item) }</option> | |||||
}) | }) | ||||
} | } | ||||
</select> | </select> | ||||
@@ -189,8 +189,8 @@ export class JsonSchema_boolean extends Component { | |||||
return (<Select className={ errors.length ? "invalid" : ""} | return (<Select className={ errors.length ? "invalid" : ""} | ||||
title={ errors.length ? errors : ""} | title={ errors.length ? errors : ""} | ||||
value={ String(value) } | value={ String(value) } | ||||
allowedValues={ fromJS(["true", "false"]) } | |||||
allowEmptyValue={ true } | |||||
allowedValues={ fromJS(schema.enum || ["true", "false"]) } | |||||
allowEmptyValue={ !this.props.required } | |||||
onChange={ this.onEnumChange }/>) | onChange={ this.onEnumChange }/>) | ||||
} | } | ||||
} | } |
@@ -85,7 +85,7 @@ describe("<JsonSchemaForm/>", function(){ | |||||
expect(wrapper.find("select option").eq(1).text()).toEqual("true") | expect(wrapper.find("select option").eq(1).text()).toEqual("true") | ||||
expect(wrapper.find("select option").eq(2).text()).toEqual("false") | expect(wrapper.find("select option").eq(2).text()).toEqual("false") | ||||
}) | }) | ||||
it("should render the correct options for a required enum boolean parameter", function(){ | it("should render the correct options for a required enum boolean parameter", function(){ | ||||
let props = { | let props = { | ||||
@@ -105,7 +105,7 @@ describe("<JsonSchemaForm/>", function(){ | |||||
expect(wrapper.find("select").length).toEqual(1) | expect(wrapper.find("select").length).toEqual(1) | ||||
expect(wrapper.find("select option").length).toEqual(1) | expect(wrapper.find("select option").length).toEqual(1) | ||||
expect(wrapper.find("select option").eq(1).text()).toEqual("true") | |||||
expect(wrapper.find("select option").first().text()).toEqual("true") | |||||
}) | }) | ||||
}) | }) | ||||
}) | }) |