Fix failing test

This commit is contained in:
Kyle Shockey
2017-11-29 19:21:20 -06:00
parent 8d1d15ca4a
commit 5224932cf9
3 changed files with 5 additions and 5 deletions

View File

@@ -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>

View File

@@ -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"]) } allowedValues={ fromJS(schema.enum || ["true", "false"]) }
allowEmptyValue={ true } allowEmptyValue={ !this.props.required }
onChange={ this.onEnumChange }/>) onChange={ this.onEnumChange }/>)
} }
} }

View File

@@ -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")
}) })
}) })
}) })