mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
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();
|
|
});
|
|
test('content not rendered when data property is falsey', () => {
|
|
const wrapper = mount(
|
|
<AnsibleSelect
|
|
selected="foo"
|
|
selectChange={() => { }}
|
|
labelName={label}
|
|
data={null}
|
|
/>
|
|
);
|
|
expect(wrapper.find('FormGroup')).toHaveLength(0);
|
|
expect(wrapper.find('Select')).toHaveLength(0);
|
|
});
|
|
});
|