Only update selected instance groups if the select button is clicked in the modal

This commit is contained in:
mabashian
2019-01-30 15:27:02 -05:00
parent 6ed36daef7
commit 0e9e17f957
4 changed files with 141 additions and 90 deletions

View File

@@ -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: {