Add support for deleting templates on templates list (#266)

Adds support for deleting templates from the templates list
This commit is contained in:
Michael Abashian
2019-06-17 13:52:05 -04:00
committed by GitHub
parent 4e45a3b365
commit 7a5cf4b81c
7 changed files with 174 additions and 40 deletions

View File

@@ -1,6 +1,5 @@
import React from 'react';
import { createMemoryHistory } from 'history';
import { mountWithContexts } from '../../../enzymeHelpers';
import { mountWithContexts, waitForElement } from '../../../enzymeHelpers';
import OrganizationsList, { _OrganizationsList } from '../../../../src/pages/Organizations/screens/OrganizationsList';
import { OrganizationsAPI } from '../../../../src/api';
@@ -122,25 +121,16 @@ describe('<OrganizationsList />', () => {
expect(fetchOrgs).toBeCalled();
});
test('error is thrown when org not successfully deleted from api', async () => {
const history = createMemoryHistory({
initialEntries: ['organizations?order_by=name&page=1&page_size=5'],
});
wrapper = mountWithContexts(
<OrganizationsList />,
{ context: { router: { history } } }
);
await wrapper.setState({
test('error is shown when org not successfully deleted from api', async () => {
OrganizationsAPI.destroy = () => Promise.reject();
wrapper = mountWithContexts(<OrganizationsList />);
wrapper.find('OrganizationsList').setState({
organizations: mockAPIOrgsList.data.results,
itemCount: 3,
isInitialized: true,
selected: [...mockAPIOrgsList.data.results].push({
name: 'Organization 6',
id: 'a',
})
selected: mockAPIOrgsList.data.results.slice(0, 1)
});
wrapper.update();
const component = wrapper.find('OrganizationsList');
component.instance().handleOrgDelete();
wrapper.find('ToolbarDeleteButton').prop('onDelete')();
await waitForElement(wrapper, 'Modal', (el) => el.props().isOpen === true && el.props().title === 'Error!');
});
});