1
0
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:
kialam 2019-01-07 17:17:22 -05:00
parent 517ef8a2c9
commit 395e30509b
No known key found for this signature in database
GPG Key ID: 2D0E60E4B8C7EA0F
3 changed files with 26 additions and 20 deletions

View File

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

View File

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

View File

@ -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() {