mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 01:47:31 -02:30
Fix linter errors and add test to AnsibleSelect component.
This commit is contained in:
@@ -41,4 +41,16 @@ describe('<AnsibleSelect />', () => {
|
|||||||
expect(wrapper.find('FormGroup')).toHaveLength(0);
|
expect(wrapper.find('FormGroup')).toHaveLength(0);
|
||||||
expect(wrapper.find('Select')).toHaveLength(0);
|
expect(wrapper.find('Select')).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
test('Returns correct select options if defaultSelected props is passed', () => {
|
||||||
|
const wrapper = mount(
|
||||||
|
<AnsibleSelect
|
||||||
|
selected="foo"
|
||||||
|
selectChange={() => { }}
|
||||||
|
labelName={label}
|
||||||
|
data={mockData}
|
||||||
|
defaultSelected={mockData[1]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
expect(wrapper.find('Select')).toHaveLength(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,9 +39,8 @@ class AnsibleSelect extends React.Component {
|
|||||||
<FormGroup label={labelName} fieldId="ansible-select">
|
<FormGroup label={labelName} fieldId="ansible-select">
|
||||||
<Select value={selected} onChange={this.onSelectChange} aria-label="Select Input">
|
<Select value={selected} onChange={this.onSelectChange} aria-label="Select Input">
|
||||||
<SelectOption isDisabled key="" value="" label={`Use Default ${labelName}`} />
|
<SelectOption isDisabled key="" value="" label={`Use Default ${labelName}`} />
|
||||||
{data.map((datum) =>
|
{data.map((datum) => (datum !== defaultSelected
|
||||||
datum !== defaultSelected ?
|
? (<SelectOption key={datum} value={datum} label={datum} />) : null))
|
||||||
(<SelectOption key={datum} value={datum} label={datum} />) : null)
|
|
||||||
}
|
}
|
||||||
</Select>
|
</Select>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class OrganizationAdd extends React.Component {
|
|||||||
this.onCancel = this.onCancel.bind(this);
|
this.onCancel = this.onCancel.bind(this);
|
||||||
this.updateSelectedInstanceGroups = this.updateSelectedInstanceGroups.bind(this);
|
this.updateSelectedInstanceGroups = this.updateSelectedInstanceGroups.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
name: '',
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user