diff --git a/__tests__/components/Lookup.test.jsx b/__tests__/components/Lookup.test.jsx
index cf2c61c014..6da734e5f7 100644
--- a/__tests__/components/Lookup.test.jsx
+++ b/__tests__/components/Lookup.test.jsx
@@ -26,7 +26,9 @@ describe('', () => {
);
expect(spy).not.toHaveBeenCalled();
- wrapper.find('#search').simulate('click');
+ debugger;
+ const searchItem = wrapper.find('.pf-c-input-group__text#search');
+ searchItem.first().simulate('click');
expect(spy).toHaveBeenCalled();
});
test('calls "onChecked" when a user changes a checkbox', () => {
@@ -40,7 +42,9 @@ describe('', () => {
/>
);
- wrapper.find('#search').simulate('click');
+ debugger;
+ const searchItem = wrapper.find('.pf-c-input-group__text#search');
+ searchItem.first().simulate('click');
wrapper.find('input[type="checkbox"]').simulate('change');
expect(spy).toHaveBeenCalled();
});
@@ -56,7 +60,8 @@ describe('', () => {
/>
);
- wrapper.find('.awx-c-icon--remove').simulate('click');
+ const removeIcon = wrapper.find('.awx-c-icon--remove').first();
+ removeIcon.simulate('click');
expect(spy).toHaveBeenCalled();
});
test('"wrapTags" method properly handles data', () => {
diff --git a/__tests__/pages/Organizations/screens/OrganizationAdd.test.jsx b/__tests__/pages/Organizations/screens/OrganizationAdd.test.jsx
index 295e5801a7..ad0ef6fc8f 100644
--- a/__tests__/pages/Organizations/screens/OrganizationAdd.test.jsx
+++ b/__tests__/pages/Organizations/screens/OrganizationAdd.test.jsx
@@ -57,28 +57,19 @@ describe('', () => {
wrapper.find('button.at-C-CancelButton').prop('onClick')();
expect(spy).toBeCalled();
});
- test('API response data is formatted properly', () => {
- const mockData = { data: { results: [{ name: 'test instance', id: 1 }] } };
- const promise = Promise.resolve(mockData);
- return promise.then(({ data }) => {
- const expected = [{ id: 1, name: 'test instance', isChecked: false }];
- const results = OrganizationAdd.WrappedComponent.prototype.format(data);
- expect(results).toEqual(expected);
- });
- });
test('API response is formatted properly', (done) => {
- const spy = jest.spyOn(OrganizationAdd.WrappedComponent.prototype, 'format');
- const mockedResp = { data: { id: 1, name: 'foo bar' } };
+ const mockedResp = { data: { results: [{ name: 'test instance', id: 1 }] } };
const api = { getInstanceGroups: jest.fn().mockResolvedValue(mockedResp) };
- mount(
+ const wrapper = mount(
);
setImmediate(() => {
- expect(spy).toHaveBeenCalled();
+ const orgAddElem = wrapper.find('OrganizationAdd');
+ expect([{ id: 1, isChecked: false, name: 'test instance' }]).toEqual(orgAddElem.state().results);
done();
});
});
diff --git a/src/pages/Organizations/screens/OrganizationAdd.jsx b/src/pages/Organizations/screens/OrganizationAdd.jsx
index f94080236d..eeff621393 100644
--- a/src/pages/Organizations/screens/OrganizationAdd.jsx
+++ b/src/pages/Organizations/screens/OrganizationAdd.jsx
@@ -23,16 +23,17 @@ import Lookup from '../../../components/Lookup';
import AnsibleSelect from '../../../components/AnsibleSelect';
const { light } = PageSectionVariants;
-class OrganizationAdd extends React.Component {
- static format (data) {
- const results = data.results.map((result) => ({
- id: result.id,
- name: result.name,
- isChecked: false
- }));
- return results;
- }
+const format = (data) => {
+ const results = data.results.map((result) => ({
+ id: result.id,
+ name: result.name,
+ isChecked: false
+ }));
+ return results;
+};
+
+class OrganizationAdd extends React.Component {
constructor (props) {
super(props);
@@ -43,7 +44,6 @@ class OrganizationAdd extends React.Component {
this.resetForm = this.resetForm.bind(this);
this.onSuccess = this.onSuccess.bind(this);
this.onCancel = this.onCancel.bind(this);
- this.format = this.format.bind(this);
}
state = {
@@ -59,7 +59,7 @@ class OrganizationAdd extends React.Component {
const { api } = this.props;
try {
const { data } = await api.getInstanceGroups();
- const results = this.format(data);
+ const results = format(data);
this.setState({ results });
} catch (error) {
this.setState({ getInstanceGroupsError: error });