mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
prettier
This commit is contained in:
parent
77b68e0eb7
commit
6d00d43273
@ -210,7 +210,9 @@ class MultiSelect extends Component {
|
|||||||
{value.map(item => (
|
{value.map(item => (
|
||||||
<Chip
|
<Chip
|
||||||
key={item.id}
|
key={item.id}
|
||||||
onClick={() => { this.removeItem(item); }}
|
onClick={() => {
|
||||||
|
this.removeItem(item);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{item.name}
|
{item.name}
|
||||||
</Chip>
|
</Chip>
|
||||||
|
@ -63,9 +63,15 @@ describe('<MultiSelect />', () => {
|
|||||||
wrapper.update();
|
wrapper.update();
|
||||||
const event = {
|
const event = {
|
||||||
preventDefault: () => {},
|
preventDefault: () => {},
|
||||||
target: wrapper.find('DropdownItem').at(1).getDOMNode(),
|
target: wrapper
|
||||||
|
.find('DropdownItem')
|
||||||
|
.at(1)
|
||||||
|
.getDOMNode(),
|
||||||
};
|
};
|
||||||
wrapper.find('DropdownItem').at(1).invoke('onClick')(event);
|
wrapper
|
||||||
|
.find('DropdownItem')
|
||||||
|
.at(1)
|
||||||
|
.invoke('onClick')(event);
|
||||||
|
|
||||||
expect(onAddNewItem).toHaveBeenCalledWith(options[1]);
|
expect(onAddNewItem).toHaveBeenCalledWith(options[1]);
|
||||||
const newVal = onChange.mock.calls[0][0];
|
const newVal = onChange.mock.calls[0][0];
|
||||||
@ -86,7 +92,10 @@ describe('<MultiSelect />', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
wrapper.find('Chip').at(1).invoke('onClick')();
|
wrapper
|
||||||
|
.find('Chip')
|
||||||
|
.at(1)
|
||||||
|
.invoke('onClick')();
|
||||||
|
|
||||||
expect(onRemoveItem).toHaveBeenCalledWith(value[1]);
|
expect(onRemoveItem).toHaveBeenCalledWith(value[1]);
|
||||||
const newVal = onChange.mock.calls[0][0];
|
const newVal = onChange.mock.calls[0][0];
|
||||||
|
@ -57,7 +57,7 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
expect(wrapper.find('JobTemplateForm').length).toBe(1);
|
expect(wrapper.find('JobTemplateForm').length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should render Job Template Form with default values', async done => {
|
test('should render Job Template Form with default values', async () => {
|
||||||
const wrapper = mountWithContexts(<JobTemplateAdd />);
|
const wrapper = mountWithContexts(<JobTemplateAdd />);
|
||||||
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
||||||
expect(wrapper.find('input#template-description').text()).toBe(
|
expect(wrapper.find('input#template-description').text()).toBe(
|
||||||
@ -80,10 +80,9 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
expect(wrapper.find('input#template-name').text()).toBe(defaultProps.name);
|
expect(wrapper.find('input#template-name').text()).toBe(defaultProps.name);
|
||||||
expect(wrapper.find('PlaybookSelect')).toHaveLength(1);
|
expect(wrapper.find('PlaybookSelect')).toHaveLength(1);
|
||||||
expect(wrapper.find('ProjectLookup').prop('value')).toBe(null);
|
expect(wrapper.find('ProjectLookup').prop('value')).toBe(null);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handleSubmit should post to api', async done => {
|
test('handleSubmit should post to api', async () => {
|
||||||
JobTemplatesAPI.create.mockResolvedValueOnce({
|
JobTemplatesAPI.create.mockResolvedValueOnce({
|
||||||
data: {
|
data: {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -99,7 +98,7 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
values: {
|
values: {
|
||||||
...jobTemplateData,
|
...jobTemplateData,
|
||||||
labels: [],
|
labels: [],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
() => resolve()
|
() => resolve()
|
||||||
);
|
);
|
||||||
@ -108,10 +107,9 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
wrapper.find('form').simulate('submit');
|
wrapper.find('form').simulate('submit');
|
||||||
await sleep(1);
|
await sleep(1);
|
||||||
expect(JobTemplatesAPI.create).toHaveBeenCalledWith(jobTemplateData);
|
expect(JobTemplatesAPI.create).toHaveBeenCalledWith(jobTemplateData);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should navigate to job template detail after form submission', async done => {
|
test('should navigate to job template detail after form submission', async () => {
|
||||||
const history = {
|
const history = {
|
||||||
push: jest.fn(),
|
push: jest.fn(),
|
||||||
};
|
};
|
||||||
@ -133,10 +131,9 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
expect(history.push).toHaveBeenCalledWith(
|
expect(history.push).toHaveBeenCalledWith(
|
||||||
'/templates/job_template/1/details'
|
'/templates/job_template/1/details'
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should navigate to templates list when cancel is clicked', async done => {
|
test('should navigate to templates list when cancel is clicked', async () => {
|
||||||
const history = {
|
const history = {
|
||||||
push: jest.fn(),
|
push: jest.fn(),
|
||||||
};
|
};
|
||||||
@ -146,6 +143,5 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
||||||
wrapper.find('button[aria-label="Cancel"]').invoke('onClick')();
|
wrapper.find('button[aria-label="Cancel"]').invoke('onClick')();
|
||||||
expect(history.push).toHaveBeenCalledWith('/templates');
|
expect(history.push).toHaveBeenCalledWith('/templates');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -178,7 +178,7 @@ describe('<JobTemplateEdit />', () => {
|
|||||||
{ id: 4, name: 'Bar', isNew: true },
|
{ id: 4, name: 'Bar', isNew: true },
|
||||||
{ id: 5, name: 'Maple' },
|
{ id: 5, name: 'Maple' },
|
||||||
{ id: 6, name: 'Tree' },
|
{ id: 6, name: 'Tree' },
|
||||||
]
|
];
|
||||||
JobTemplatesAPI.update.mockResolvedValue({
|
JobTemplatesAPI.update.mockResolvedValue({
|
||||||
data: { ...updatedTemplateData },
|
data: { ...updatedTemplateData },
|
||||||
});
|
});
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import { LabelsAPI } from '@api';
|
import { LabelsAPI } from '@api';
|
||||||
import { sleep} from '@testUtils/testUtils';
|
import { sleep } from '@testUtils/testUtils';
|
||||||
import LabelSelect from './LabelSelect';
|
import LabelSelect from './LabelSelect';
|
||||||
|
|
||||||
jest.mock('@api');
|
jest.mock('@api');
|
||||||
|
|
||||||
const options = [
|
const options = [{ id: 1, name: 'one' }, { id: 2, name: 'two' }];
|
||||||
{ id: 1, name: 'one' },
|
|
||||||
{ id: 2, name: 'two' },
|
|
||||||
];
|
|
||||||
|
|
||||||
describe('<LabelSelect />', () => {
|
describe('<LabelSelect />', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -47,7 +44,7 @@ describe('<LabelSelect />', () => {
|
|||||||
expect(LabelsAPI.read).toHaveBeenCalledTimes(2);
|
expect(LabelsAPI.read).toHaveBeenCalledTimes(2);
|
||||||
expect(wrapper.find('MultiSelect').prop('options')).toEqual([
|
expect(wrapper.find('MultiSelect').prop('options')).toEqual([
|
||||||
...options,
|
...options,
|
||||||
...options
|
...options,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@ describe('<PlaybookSelect />', () => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
})
|
});
|
||||||
|
|
||||||
test('should reload playbooks when project value changes', () => {
|
test('should reload playbooks when project value changes', () => {
|
||||||
const wrapper = mountWithContexts(
|
const wrapper = mountWithContexts(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable import/prefer-default-export */
|
/* eslint-disable import/prefer-default-export */
|
||||||
export function getAddedAndRemoved (original, current) {
|
export function getAddedAndRemoved(original, current) {
|
||||||
original = original || [];
|
original = original || [];
|
||||||
current = current || [];
|
current = current || [];
|
||||||
const added = [];
|
const added = [];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {getAddedAndRemoved} from './lists';
|
import { getAddedAndRemoved } from './lists';
|
||||||
|
|
||||||
const one = { id: 1 };
|
const one = { id: 1 };
|
||||||
const two = { id: 2 };
|
const two = { id: 2 };
|
||||||
|
Loading…
Reference in New Issue
Block a user