mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
9bc87b3e80
- Move API GET request to /v2/config out to the top level of our App. - Store /v2/config response data in sessionStorage. - Use Context API to pass down relevant data to Organizations component. - Wrap our AnsibleSelect component as a context consumer and pass in the list of Ansible Environments of the logged in user. - Clear sessionStorage object when user logs out. - Update unit tests.
32 lines
895 B
JavaScript
32 lines
895 B
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import AnsibleSelect from '../../src/components/AnsibleSelect';
|
|
|
|
const label = "test select"
|
|
const mockData = ["/venv/baz/", "/venv/ansible/"];
|
|
describe('<AnsibleSelect />', () => {
|
|
test('initially renders succesfully', async () => {
|
|
mount(
|
|
<AnsibleSelect
|
|
selected="foo"
|
|
selectChange={() => { }}
|
|
labelName={label}
|
|
data={mockData}
|
|
/>
|
|
);
|
|
});
|
|
test('calls "onSelectChange" on dropdown select change', () => {
|
|
const spy = jest.spyOn(AnsibleSelect.prototype, 'onSelectChange');
|
|
const wrapper = mount(
|
|
<AnsibleSelect
|
|
selected="foo"
|
|
selectChange={() => { }}
|
|
labelName={label}
|
|
data={mockData}
|
|
/>
|
|
);
|
|
expect(spy).not.toHaveBeenCalled();
|
|
wrapper.find('select').simulate('change');
|
|
expect(spy).toHaveBeenCalled();
|
|
});
|
|
}); |