Browse Source

Fix failing test

bubble
Kyle Shockey 6 years ago
parent
commit
5224932cf9
3 changed files with 5 additions and 5 deletions
  1. +1
    -1
      src/core/components/layout-utils.jsx
  2. +2
    -2
      src/core/json-schema-components.js
  3. +2
    -2
      test/components/json-schema-form.js

+ 1
- 1
src/core/components/layout-utils.jsx 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>


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

+ 2
- 2
test/components/json-schema-form.js 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")
}) })
}) })
}) })

Loading…
Cancel
Save