mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 02:47:35 -02:30
Only update selected instance groups if the select button is clicked in the modal
This commit is contained in:
@@ -93,6 +93,26 @@ describe('<OrganizationAdd />', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('updateSelectedInstanceGroups successfully sets selectedInstanceGroups state', () => {
|
||||
const wrapper = mount(
|
||||
<MemoryRouter>
|
||||
<OrganizationAdd api={{}} />
|
||||
</MemoryRouter>
|
||||
).find('OrganizationAdd');
|
||||
wrapper.instance().updateSelectedInstanceGroups([
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo'
|
||||
}
|
||||
]);
|
||||
expect(wrapper.state('selectedInstanceGroups')).toEqual([
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo'
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
test('onSelectChange successfully sets custom_virtualenv state', () => {
|
||||
const wrapper = mount(
|
||||
<MemoryRouter>
|
||||
@@ -103,41 +123,6 @@ describe('<OrganizationAdd />', () => {
|
||||
expect(wrapper.state('custom_virtualenv')).toBe('foobar');
|
||||
});
|
||||
|
||||
test('onLookupChange successfully adds/removes row from selectedInstanceGroups state', () => {
|
||||
const wrapper = mount(
|
||||
<MemoryRouter>
|
||||
<OrganizationAdd api={{}} />
|
||||
</MemoryRouter>
|
||||
).find('OrganizationAdd');
|
||||
wrapper.setState({ results: [{
|
||||
id: 1,
|
||||
name: 'foo'
|
||||
}] });
|
||||
wrapper.instance().onLookupChange({
|
||||
id: 1,
|
||||
name: 'foo'
|
||||
});
|
||||
expect(wrapper.state('results')).toEqual([{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
isChecked: true
|
||||
}]);
|
||||
expect(wrapper.state('selectedInstanceGroups')).toEqual([{
|
||||
id: 1,
|
||||
name: 'foo'
|
||||
}]);
|
||||
wrapper.instance().onLookupChange({
|
||||
id: 1,
|
||||
name: 'foo'
|
||||
});
|
||||
expect(wrapper.state('results')).toEqual([{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
isChecked: false
|
||||
}]);
|
||||
expect(wrapper.state('selectedInstanceGroups')).toEqual([]);
|
||||
});
|
||||
|
||||
test('onSubmit posts instance groups from selectedInstanceGroups', async () => {
|
||||
const createOrganizationFn = jest.fn().mockResolvedValue({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user