mirror of
https://github.com/ansible/awx.git
synced 2026-02-16 18:50:04 -03:30
- Component conditionally renders based on # of virtual environments. - User can add an Organization and associate it with a virtual environment.
40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import OrganizationAdd from '../../../../src/pages/Organizations/views/Organization.add';
|
|
|
|
describe('<OrganizationAdd />', () => {
|
|
test('initially renders succesfully', () => {
|
|
mount(
|
|
<OrganizationAdd
|
|
match={{ path: '/organizations/add', url: '/organizations/add' }}
|
|
location={{ search: '', pathname: '/organizations/add' }}
|
|
/>
|
|
);
|
|
});
|
|
test('calls "handleChange" when input values change', () => {
|
|
const spy = jest.spyOn(OrganizationAdd.prototype, 'handleChange');
|
|
const wrapper = mount(
|
|
<OrganizationAdd
|
|
match={{ path: '/organizations/add', url: '/organizations/add' }}
|
|
location={{ search: '', pathname: '/organizations/add' }}
|
|
/>
|
|
);
|
|
expect(spy).not.toHaveBeenCalled();
|
|
wrapper.find('input#add-org-form-name').simulate('change', {target: {value: 'foo'}});
|
|
wrapper.find('input#add-org-form-description').simulate('change', {target: {value: 'bar'}});
|
|
expect(spy).toHaveBeenCalledTimes(2);
|
|
});
|
|
test('calls "onSubmit" when Save button is clicked', () => {
|
|
const spy = jest.spyOn(OrganizationAdd.prototype, 'onSubmit');
|
|
const wrapper = mount(
|
|
<OrganizationAdd
|
|
match={{ path: '/organizations/add', url: '/organizations/add' }}
|
|
location={{ search: '', pathname: '/organizations/add' }}
|
|
/>
|
|
);
|
|
expect(spy).not.toHaveBeenCalled();
|
|
wrapper.find('button.at-C-SubmitButton').prop('onClick')();
|
|
expect(spy).toBeCalled();
|
|
});
|
|
});
|