Skip to content

Commit 5224932

Browse files
committed
Fix failing test
1 parent 8d1d15c commit 5224932

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/core/components/layout-utils.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class Select extends React.Component {
183183
{ allowEmptyValue ? <option value="">--</option> : null }
184184
{
185185
allowedValues.map(function (item, key) {
186-
return <option key={ key } value={ String(item) }>{ item }</option>
186+
return <option key={ key } value={ String(item) }>{ String(item) }</option>
187187
})
188188
}
189189
</select>

src/core/json-schema-components.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ export class JsonSchema_boolean extends Component {
189189
return (<Select className={ errors.length ? "invalid" : ""}
190190
title={ errors.length ? errors : ""}
191191
value={ String(value) }
192-
allowedValues={ fromJS(["true", "false"]) }
193-
allowEmptyValue={ true }
192+
allowedValues={ fromJS(schema.enum || ["true", "false"]) }
193+
allowEmptyValue={ !this.props.required }
194194
onChange={ this.onEnumChange }/>)
195195
}
196196
}

test/components/json-schema-form.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe("<JsonSchemaForm/>", function(){
8585
expect(wrapper.find("select option").eq(1).text()).toEqual("true")
8686
expect(wrapper.find("select option").eq(2).text()).toEqual("false")
8787
})
88-
88+
8989
it("should render the correct options for a required enum boolean parameter", function(){
9090

9191
let props = {
@@ -105,7 +105,7 @@ describe("<JsonSchemaForm/>", function(){
105105

106106
expect(wrapper.find("select").length).toEqual(1)
107107
expect(wrapper.find("select option").length).toEqual(1)
108-
expect(wrapper.find("select option").eq(1).text()).toEqual("true")
108+
expect(wrapper.find("select option").first().text()).toEqual("true")
109109
})
110110
})
111111
})

0 commit comments

Comments
 (0)