mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
prettier
This commit is contained in:
parent
77b68e0eb7
commit
6d00d43273
@ -210,7 +210,9 @@ class MultiSelect extends Component {
|
||||
{value.map(item => (
|
||||
<Chip
|
||||
key={item.id}
|
||||
onClick={() => { this.removeItem(item); }}
|
||||
onClick={() => {
|
||||
this.removeItem(item);
|
||||
}}
|
||||
>
|
||||
{item.name}
|
||||
</Chip>
|
||||
|
@ -63,9 +63,15 @@ describe('<MultiSelect />', () => {
|
||||
wrapper.update();
|
||||
const event = {
|
||||
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]);
|
||||
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]);
|
||||
const newVal = onChange.mock.calls[0][0];
|
||||
|
@ -57,7 +57,7 @@ describe('<JobTemplateAdd />', () => {
|
||||
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 />);
|
||||
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
||||
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('PlaybookSelect')).toHaveLength(1);
|
||||
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({
|
||||
data: {
|
||||
id: 1,
|
||||
@ -99,7 +98,7 @@ describe('<JobTemplateAdd />', () => {
|
||||
values: {
|
||||
...jobTemplateData,
|
||||
labels: [],
|
||||
}
|
||||
},
|
||||
},
|
||||
() => resolve()
|
||||
);
|
||||
@ -108,10 +107,9 @@ describe('<JobTemplateAdd />', () => {
|
||||
wrapper.find('form').simulate('submit');
|
||||
await sleep(1);
|
||||
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 = {
|
||||
push: jest.fn(),
|
||||
};
|
||||
@ -133,10 +131,9 @@ describe('<JobTemplateAdd />', () => {
|
||||
expect(history.push).toHaveBeenCalledWith(
|
||||
'/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 = {
|
||||
push: jest.fn(),
|
||||
};
|
||||
@ -146,6 +143,5 @@ describe('<JobTemplateAdd />', () => {
|
||||
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
||||
wrapper.find('button[aria-label="Cancel"]').invoke('onClick')();
|
||||
expect(history.push).toHaveBeenCalledWith('/templates');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -178,7 +178,7 @@ describe('<JobTemplateEdit />', () => {
|
||||
{ id: 4, name: 'Bar', isNew: true },
|
||||
{ id: 5, name: 'Maple' },
|
||||
{ id: 6, name: 'Tree' },
|
||||
]
|
||||
];
|
||||
JobTemplatesAPI.update.mockResolvedValue({
|
||||
data: { ...updatedTemplateData },
|
||||
});
|
||||
|
@ -1,15 +1,12 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { LabelsAPI } from '@api';
|
||||
import { sleep} from '@testUtils/testUtils';
|
||||
import { sleep } from '@testUtils/testUtils';
|
||||
import LabelSelect from './LabelSelect';
|
||||
|
||||
jest.mock('@api');
|
||||
|
||||
const options = [
|
||||
{ id: 1, name: 'one' },
|
||||
{ id: 2, name: 'two' },
|
||||
];
|
||||
const options = [{ id: 1, name: 'one' }, { id: 2, name: 'two' }];
|
||||
|
||||
describe('<LabelSelect />', () => {
|
||||
afterEach(() => {
|
||||
@ -47,7 +44,7 @@ describe('<LabelSelect />', () => {
|
||||
expect(LabelsAPI.read).toHaveBeenCalledTimes(2);
|
||||
expect(wrapper.find('MultiSelect').prop('options')).toEqual([
|
||||
...options,
|
||||
...options
|
||||
...options,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ describe('<PlaybookSelect />', () => {
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
})
|
||||
});
|
||||
|
||||
test('should reload playbooks when project value changes', () => {
|
||||
const wrapper = mountWithContexts(
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
export function getAddedAndRemoved (original, current) {
|
||||
export function getAddedAndRemoved(original, current) {
|
||||
original = original || [];
|
||||
current = current || [];
|
||||
const added = [];
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {getAddedAndRemoved} from './lists';
|
||||
import { getAddedAndRemoved } from './lists';
|
||||
|
||||
const one = { id: 1 };
|
||||
const two = { id: 2 };
|
||||
|
Loading…
Reference in New Issue
Block a user