1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00
awx/__tests__/components/AnsibleSelect.test.jsx
kialam 9bc87b3e80
Implement React Context API
- 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.
2019-01-03 15:20:08 -05:00

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