mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -03:30
Fix unit tests.
This commit is contained in:
parent
da8c3f6c43
commit
f9d615fdee
@ -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
|
||||
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user