mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 11:40:05 -03:30
Fix unit tests.
This commit is contained in:
@@ -33,19 +33,6 @@ describe('<AnsibleSelect />', () => {
|
|||||||
expect(spy).toHaveBeenCalled();
|
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', () => {
|
test('Returns correct select options if defaultSelected props is passed', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<AnsibleSelect
|
<AnsibleSelect
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { I18nProvider } from '@lingui/react';
|
import { I18nProvider } from '@lingui/react';
|
||||||
|
import { ConfigContext } from '../../../../src/context';
|
||||||
import OrganizationAdd from '../../../../src/pages/Organizations/screens/OrganizationAdd';
|
import OrganizationAdd from '../../../../src/pages/Organizations/screens/OrganizationAdd';
|
||||||
|
|
||||||
describe('<OrganizationAdd />', () => {
|
describe('<OrganizationAdd />', () => {
|
||||||
@@ -157,4 +158,37 @@ describe('<OrganizationAdd />', () => {
|
|||||||
});
|
});
|
||||||
expect(createInstanceGroupsFn).toHaveBeenCalledWith('/api/v2/organizations/1/instance_groups', 1);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user