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('', () => { test('initially renders succesfully', async () => { mount( { }} labelName={label} data={mockData} /> ); }); test('calls "onSelectChange" on dropdown select change', () => { const spy = jest.spyOn(AnsibleSelect.prototype, 'onSelectChange'); const wrapper = mount( { }} 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( { }} labelName={label} data={null} /> ); expect(wrapper.find('FormGroup')).toHaveLength(0); expect(wrapper.find('Select')).toHaveLength(0); }); });