mirror of
https://github.com/ansible/awx.git
synced 2026-03-17 17:07:33 -02:30
fix tests
This commit is contained in:
@@ -26,7 +26,9 @@ describe('<Lookup />', () => {
|
||||
</I18nProvider>
|
||||
);
|
||||
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('<Lookup />', () => {
|
||||
/>
|
||||
</I18nProvider>
|
||||
);
|
||||
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('<Lookup />', () => {
|
||||
/>
|
||||
</I18nProvider>
|
||||
);
|
||||
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', () => {
|
||||
|
||||
@@ -57,28 +57,19 @@ describe('<OrganizationAdd />', () => {
|
||||
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(
|
||||
<MemoryRouter>
|
||||
<OrganizationAdd api={api} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
setImmediate(() => {
|
||||
expect(spy).toHaveBeenCalled();
|
||||
const orgAddElem = wrapper.find('OrganizationAdd');
|
||||
expect([{ id: 1, isChecked: false, name: 'test instance' }]).toEqual(orgAddElem.state().results);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user