mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Fix linter and existing unit tests.
This commit is contained in:
parent
517ef8a2c9
commit
395e30509b
@ -120,11 +120,4 @@ describe('<App />', () => {
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('Componenet makes REST call to API_CONFIG endpoint when mounted', () => {
|
||||
api.get = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
const appWrapper = shallow(<App.WrappedComponent />);
|
||||
expect(api.get).toHaveBeenCalledTimes(1);
|
||||
expect(api.get).toHaveBeenCalledWith(API_CONFIG);
|
||||
});
|
||||
});
|
||||
|
@ -70,7 +70,7 @@ class APIClient {
|
||||
return this.http.get(endpoint);
|
||||
}
|
||||
|
||||
getInstanceGroups (){
|
||||
getInstanceGroups () {
|
||||
return this.http.get(API_INSTANCE_GROUPS);
|
||||
}
|
||||
|
||||
@ -82,7 +82,6 @@ class APIClient {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default APIClient;
|
||||
|
@ -73,11 +73,20 @@ class OrganizationAdd extends React.Component {
|
||||
async onSubmit() {
|
||||
const { api } = this.props;
|
||||
const data = Object.assign({}, { ...this.state });
|
||||
const { data: response } = await api.createOrganization(data);
|
||||
const url = response.related.instance_groups;
|
||||
const selected = this.state.results.filter(group => group.isChecked);
|
||||
await api.createInstanceGroups(url, selected);
|
||||
this.resetForm();
|
||||
try {
|
||||
const { data: response } = await api.createOrganization(data);
|
||||
const url = response.related.instance_groups;
|
||||
const selected = this.state.results.filter(group => group.isChecked);
|
||||
try {
|
||||
await api.createInstanceGroups(url, selected);
|
||||
this.resetForm();
|
||||
} catch (err) {
|
||||
this.setState({ createInstanceGroupsError: err })
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.setState({ onSubmitError: err })
|
||||
}
|
||||
}
|
||||
|
||||
onCancel() {
|
||||
@ -86,12 +95,17 @@ class OrganizationAdd extends React.Component {
|
||||
|
||||
async componentDidMount() {
|
||||
const { api } = this.props;
|
||||
const { data } = await api.getInstanceGroups();
|
||||
let results = [];
|
||||
data.results.map((result) => {
|
||||
results.push({ id: result.id, name: result.name, isChecked: false });
|
||||
})
|
||||
this.setState({ results });
|
||||
try {
|
||||
const { data } = await api.getInstanceGroups();
|
||||
let results = [];
|
||||
data.results.map((result) => {
|
||||
results.push({ id: result.id, name: result.name, isChecked: false });
|
||||
})
|
||||
this.setState({ results });
|
||||
} catch (error) {
|
||||
this.setState({ getInstanceGroupsError: error })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
|
Loading…
Reference in New Issue
Block a user