Fix unit tests.

This commit is contained in:
kialam 2019-02-19 11:28:17 -05:00
parent da8c3f6c43
commit f9d615fdee
No known key found for this signature in database
GPG Key ID: 2D0E60E4B8C7EA0F
2 changed files with 34 additions and 13 deletions

View File

@ -33,19 +33,6 @@ describe('<AnsibleSelect />', () => {
expect(spy).toHaveBeenCalled();
});
test('content not rendered when data property is falsey', () => {
const wrapper = mount(
<AnsibleSelect
value="foo"
name="bar"
onChange={() => { }}
label={label}
data={null}
/>
);
expect(wrapper.find('FormGroup')).toHaveLength(0);
expect(wrapper.find('Select')).toHaveLength(0);
});
test('Returns correct select options if defaultSelected props is passed', () => {
const wrapper = mount(
<AnsibleSelect

View File

@ -2,6 +2,7 @@ import React from 'react';
import { mount } from 'enzyme';
import { MemoryRouter } from 'react-router-dom';
import { I18nProvider } from '@lingui/react';
import { ConfigContext } from '../../../../src/context';
import OrganizationAdd from '../../../../src/pages/Organizations/screens/OrganizationAdd';
describe('<OrganizationAdd />', () => {
@ -157,4 +158,37 @@ describe('<OrganizationAdd />', () => {
});
expect(createInstanceGroupsFn).toHaveBeenCalledWith('/api/v2/organizations/1/instance_groups', 1);
});
test('AnsibleSelect component renders if there are virtual environments', () => {
const config = {
custom_virtualenvs: ['foo', 'bar'],
};
const wrapper = mount(
<MemoryRouter>
<I18nProvider>
<ConfigContext.Provider value={config}>
<OrganizationAdd api={{}} />
</ConfigContext.Provider>
</I18nProvider>
</MemoryRouter>
).find('OrganizationAdd').find('AnsibleSelect');
expect(wrapper.find('Select')).toHaveLength(1);
expect(wrapper.find('SelectOption')).toHaveLength(2);
});
test('AnsibleSelect component does not render if there are 0 virtual environments', () => {
const config = {
custom_virtualenvs: [],
};
const wrapper = mount(
<MemoryRouter>
<I18nProvider>
<ConfigContext.Provider value={config}>
<OrganizationAdd api={{}} />
</ConfigContext.Provider>
</I18nProvider>
</MemoryRouter>
).find('OrganizationAdd').find('AnsibleSelect');
expect(wrapper.find('Select')).toHaveLength(0);
});
});