mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 12:41:19 -03:30
fixing JT Form tests post-rebase
This commit is contained in:
parent
9777b79818
commit
be6f5e18ae
@ -0,0 +1,26 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import CollapsibleSection from './CollapsibleSection';
|
||||
|
||||
describe('<CollapsibleSection>', () => {
|
||||
it('should render contents', () => {
|
||||
const wrapper = shallow(
|
||||
<CollapsibleSection label="Advanced">foo</CollapsibleSection>
|
||||
);
|
||||
expect(wrapper.find('Button > *').prop('isExpanded')).toEqual(false);
|
||||
expect(wrapper.find('ExpandingContainer').prop('isExpanded')).toEqual(
|
||||
false
|
||||
);
|
||||
expect(wrapper.find('ExpandingContainer').prop('children')).toEqual('foo');
|
||||
});
|
||||
|
||||
it('should toggle when clicked', () => {
|
||||
const wrapper = shallow(
|
||||
<CollapsibleSection label="Advanced">foo</CollapsibleSection>
|
||||
);
|
||||
expect(wrapper.find('Button > *').prop('isExpanded')).toEqual(false);
|
||||
wrapper.find('Button').simulate('click');
|
||||
expect(wrapper.find('Button > *').prop('isExpanded')).toEqual(true);
|
||||
expect(wrapper.find('ExpandingContainer').prop('isExpanded')).toEqual(true);
|
||||
});
|
||||
});
|
||||
@ -29,6 +29,8 @@ const ToolbarItem = styled(PFToolbarItem)`
|
||||
}
|
||||
`;
|
||||
|
||||
// TODO: Recommend renaming this component to avoid confusion
|
||||
// with ExpandingContainer
|
||||
class ExpandCollapse extends React.Component {
|
||||
render() {
|
||||
const { isCompact, onCompact, onExpand, i18n } = this.props;
|
||||
|
||||
@ -58,7 +58,7 @@ function JobTemplateAdd({ history, i18n }) {
|
||||
]);
|
||||
}
|
||||
|
||||
function submitInstanceGroups(templateId, addedGroups) {
|
||||
function submitInstanceGroups(templateId, addedGroups = []) {
|
||||
const associatePromises = addedGroups.map(group =>
|
||||
JobTemplatesAPI.associateInstanceGroup(templateId, group.id)
|
||||
);
|
||||
|
||||
@ -62,7 +62,7 @@ describe('<JobTemplateAdd />', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
test('handleSubmit should post to api', async done => {
|
||||
test.only('handleSubmit should post to api', async done => {
|
||||
const jobTemplateData = {
|
||||
description: 'Baz',
|
||||
inventory: 1,
|
||||
@ -70,6 +70,9 @@ describe('<JobTemplateAdd />', () => {
|
||||
name: 'Foo',
|
||||
playbook: 'Bar',
|
||||
project: 2,
|
||||
verbosity: '0',
|
||||
job_tags: '',
|
||||
skip_tags: '',
|
||||
};
|
||||
JobTemplatesAPI.create.mockResolvedValueOnce({
|
||||
data: {
|
||||
@ -106,6 +109,9 @@ describe('<JobTemplateAdd />', () => {
|
||||
name: 'Foo',
|
||||
playbook: 'Bar',
|
||||
project: 2,
|
||||
verbosity: '0',
|
||||
job_tags: '',
|
||||
skip_tags: '',
|
||||
};
|
||||
JobTemplatesAPI.create.mockResolvedValueOnce({
|
||||
data: {
|
||||
@ -118,7 +124,7 @@ describe('<JobTemplateAdd />', () => {
|
||||
context: { router: { history } },
|
||||
});
|
||||
|
||||
await wrapper.find('JobTemplateForm').prop('handleSubmit')(jobTemplateData);
|
||||
await wrapper.find('JobTemplateForm').invoke('handleSubmit')(jobTemplateData);
|
||||
await sleep(0);
|
||||
expect(history.push).toHaveBeenCalledWith(
|
||||
'/templates/job_template/1/details'
|
||||
@ -134,7 +140,7 @@ describe('<JobTemplateAdd />', () => {
|
||||
context: { router: { history } },
|
||||
});
|
||||
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
||||
wrapper.find('button[aria-label="Cancel"]').prop('onClick')();
|
||||
wrapper.find('button[aria-label="Cancel"]').invoke('onClick')();
|
||||
expect(history.push).toHaveBeenCalledWith('/templates');
|
||||
done();
|
||||
});
|
||||
|
||||
@ -15,6 +15,8 @@ const mockJobTemplate = {
|
||||
project: 3,
|
||||
playbook: 'Baz',
|
||||
type: 'job_template',
|
||||
job_tags: '',
|
||||
skip_tags: '',
|
||||
summary_fields: {
|
||||
user_capabilities: {
|
||||
edit: true,
|
||||
|
||||
@ -177,7 +177,7 @@ describe('<JobTemplateForm />', () => {
|
||||
});
|
||||
|
||||
test('handleNewLabel should arrange new labels properly', async () => {
|
||||
const event = { key: 'Enter' };
|
||||
const event = { key: 'Enter', preventDefault: () => {} };
|
||||
const wrapper = mountWithContexts(
|
||||
<JobTemplateForm
|
||||
template={mockData}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user