mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
update the rest of the organizations tests
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { I18nProvider } from '@lingui/react';
|
import { I18nProvider } from '@lingui/react';
|
||||||
|
import { mountWithContexts } from '../../../enzymeHelpers';
|
||||||
import OrganizationListItem from '../../../../src/pages/Organizations/components/OrganizationListItem';
|
import OrganizationListItem from '../../../../src/pages/Organizations/components/OrganizationListItem';
|
||||||
|
|
||||||
describe('<OrganizationListItem />', () => {
|
describe('<OrganizationListItem />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mountWithContexts(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
||||||
<OrganizationListItem />
|
<OrganizationListItem />
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
|
||||||
import { MemoryRouter, Router } from 'react-router-dom';
|
|
||||||
import { createMemoryHistory } from 'history';
|
import { createMemoryHistory } from 'history';
|
||||||
import { I18nProvider } from '@lingui/react';
|
import { mountWithContexts } from '../../../enzymeHelpers';
|
||||||
import { sleep } from '../../../testUtils';
|
import { sleep } from '../../../testUtils';
|
||||||
import OrganizationTeamsList from '../../../../src/pages/Organizations/components/OrganizationTeamsList';
|
import OrganizationTeamsList from '../../../../src/pages/Organizations/components/OrganizationTeamsList';
|
||||||
|
|
||||||
@@ -20,20 +18,16 @@ describe('<OrganizationTeamsList />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mountWithContexts(
|
||||||
<I18nProvider>
|
<OrganizationTeamsList
|
||||||
<MemoryRouter>
|
teams={mockData}
|
||||||
<OrganizationTeamsList
|
itemCount={7}
|
||||||
teams={mockData}
|
queryParams={{
|
||||||
itemCount={7}
|
page: 1,
|
||||||
queryParams={{
|
page_size: 5,
|
||||||
page: 1,
|
order_by: 'name',
|
||||||
page_size: 5,
|
}}
|
||||||
order_by: 'name',
|
/>
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
</I18nProvider>
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -42,20 +36,16 @@ describe('<OrganizationTeamsList />', () => {
|
|||||||
const history = createMemoryHistory({
|
const history = createMemoryHistory({
|
||||||
initialEntries: ['/organizations/1/teams'],
|
initialEntries: ['/organizations/1/teams'],
|
||||||
});
|
});
|
||||||
const wrapper = mount(
|
const wrapper = mountWithContexts(
|
||||||
<Router history={history}>
|
<OrganizationTeamsList
|
||||||
<I18nProvider>
|
teams={mockData}
|
||||||
<OrganizationTeamsList
|
itemCount={7}
|
||||||
teams={mockData}
|
queryParams={{
|
||||||
itemCount={7}
|
page: 1,
|
||||||
queryParams={{
|
page_size: 5,
|
||||||
page: 1,
|
order_by: 'name',
|
||||||
page_size: 5,
|
}}
|
||||||
order_by: 'name',
|
/>, { context: { router: { history } } }
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</I18nProvider>
|
|
||||||
</Router>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const toolbar = wrapper.find('DataListToolbar');
|
const toolbar = wrapper.find('DataListToolbar');
|
||||||
@@ -78,20 +68,16 @@ describe('<OrganizationTeamsList />', () => {
|
|||||||
const history = createMemoryHistory({
|
const history = createMemoryHistory({
|
||||||
initialEntries: ['/organizations/1/teams'],
|
initialEntries: ['/organizations/1/teams'],
|
||||||
});
|
});
|
||||||
const wrapper = mount(
|
const wrapper = mountWithContexts(
|
||||||
<Router history={history}>
|
<OrganizationTeamsList
|
||||||
<I18nProvider>
|
teams={mockData}
|
||||||
<OrganizationTeamsList
|
itemCount={7}
|
||||||
teams={mockData}
|
queryParams={{
|
||||||
itemCount={7}
|
page: 1,
|
||||||
queryParams={{
|
page_size: 5,
|
||||||
page: 1,
|
order_by: 'name',
|
||||||
page_size: 5,
|
}}
|
||||||
order_by: 'name',
|
/>, { context: { router: { history } } }
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</I18nProvider>
|
|
||||||
</Router>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const pagination = wrapper.find('Pagination');
|
const pagination = wrapper.find('Pagination');
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mountWithContexts } from '../../../../enzymeHelpers';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
|
||||||
import { I18nProvider } from '@lingui/react';
|
|
||||||
import OrganizationDetail from '../../../../../src/pages/Organizations/screens/Organization/OrganizationDetail';
|
import OrganizationDetail from '../../../../../src/pages/Organizations/screens/Organization/OrganizationDetail';
|
||||||
|
|
||||||
describe('<OrganizationDetail />', () => {
|
describe('<OrganizationDetail />', () => {
|
||||||
@@ -14,33 +12,21 @@ describe('<OrganizationDetail />', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mountWithContexts(
|
||||||
<I18nProvider>
|
<OrganizationDetail
|
||||||
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
organization={mockDetails}
|
||||||
<OrganizationDetail
|
/>
|
||||||
match={{ params: { id: '1' } }}
|
|
||||||
organization={mockDetails}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
</I18nProvider>
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should request instance groups from api', () => {
|
test('should request instance groups from api', () => {
|
||||||
const getOrganizationInstanceGroups = jest.fn();
|
const getOrganizationInstanceGroups = jest.fn();
|
||||||
mount(
|
mountWithContexts(
|
||||||
<I18nProvider>
|
<OrganizationDetail
|
||||||
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
organization={mockDetails}
|
||||||
<OrganizationDetail
|
/>, { context: {
|
||||||
match={{ params: { id: '1' } }}
|
network: { api: { getOrganizationInstanceGroups }, handleHttpError: () => {} }
|
||||||
api={{
|
} }
|
||||||
getOrganizationInstanceGroups
|
|
||||||
}}
|
|
||||||
handleHttpError={() => {}}
|
|
||||||
organization={mockDetails}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
</I18nProvider>
|
|
||||||
).find('OrganizationDetail');
|
).find('OrganizationDetail');
|
||||||
|
|
||||||
expect(getOrganizationInstanceGroups).toHaveBeenCalledTimes(1);
|
expect(getOrganizationInstanceGroups).toHaveBeenCalledTimes(1);
|
||||||
@@ -54,23 +40,12 @@ describe('<OrganizationDetail />', () => {
|
|||||||
const getOrganizationInstanceGroups = jest.fn(() => (
|
const getOrganizationInstanceGroups = jest.fn(() => (
|
||||||
Promise.resolve({ data: { results: mockInstanceGroups } })
|
Promise.resolve({ data: { results: mockInstanceGroups } })
|
||||||
));
|
));
|
||||||
const wrapper = mount(
|
const wrapper = mountWithContexts(
|
||||||
<I18nProvider>
|
<OrganizationDetail
|
||||||
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
organization={mockDetails}
|
||||||
<OrganizationDetail
|
/>, { context: {
|
||||||
match={{
|
network: { api: { getOrganizationInstanceGroups }, handleHttpError: () => {} }
|
||||||
path: '/organizations/:id',
|
} }
|
||||||
url: '/organizations/1',
|
|
||||||
params: { id: '1' }
|
|
||||||
}}
|
|
||||||
organization={mockDetails}
|
|
||||||
handleHttpError={() => {}}
|
|
||||||
api={{
|
|
||||||
getOrganizationInstanceGroups
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
</I18nProvider>
|
|
||||||
).find('OrganizationDetail');
|
).find('OrganizationDetail');
|
||||||
|
|
||||||
await getOrganizationInstanceGroups();
|
await getOrganizationInstanceGroups();
|
||||||
@@ -78,19 +53,10 @@ describe('<OrganizationDetail />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should render Details', async () => {
|
test('should render Details', async () => {
|
||||||
const wrapper = mount(
|
const wrapper = mountWithContexts(
|
||||||
<I18nProvider>
|
<OrganizationDetail
|
||||||
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
organization={mockDetails}
|
||||||
<OrganizationDetail
|
/>
|
||||||
match={{
|
|
||||||
path: '/organizations/:id',
|
|
||||||
url: '/organizations/1',
|
|
||||||
params: { id: '1' }
|
|
||||||
}}
|
|
||||||
organization={mockDetails}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
</I18nProvider>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const detailWrapper = wrapper.find('Detail');
|
const detailWrapper = wrapper.find('Detail');
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mountWithContexts } from '../../../../enzymeHelpers';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
|
||||||
import { I18nProvider } from '@lingui/react';
|
|
||||||
|
|
||||||
import { NetworkProvider } from '../../../../../src/contexts/Network';
|
import OrganizationEdit from '../../../../../src/pages/Organizations/screens/Organization/OrganizationEdit';
|
||||||
|
|
||||||
import { _OrganizationEdit } from '../../../../../src/pages/Organizations/screens/Organization/OrganizationEdit';
|
|
||||||
|
|
||||||
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
|
||||||
describe('<OrganizationEdit />', () => {
|
describe('<OrganizationEdit />', () => {
|
||||||
let api;
|
let api;
|
||||||
let networkProviderValue;
|
|
||||||
|
|
||||||
const mockData = {
|
const mockData = {
|
||||||
name: 'Foo',
|
name: 'Foo',
|
||||||
@@ -30,26 +25,16 @@ describe('<OrganizationEdit />', () => {
|
|||||||
associateInstanceGroup: jest.fn(),
|
associateInstanceGroup: jest.fn(),
|
||||||
disassociate: jest.fn(),
|
disassociate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
networkProviderValue = {
|
|
||||||
api,
|
|
||||||
handleHttpError: () => {}
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handleSubmit should call api update', () => {
|
test('handleSubmit should call api update', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mountWithContexts(
|
||||||
<MemoryRouter>
|
<OrganizationEdit
|
||||||
<I18nProvider>
|
organization={mockData}
|
||||||
<NetworkProvider value={networkProviderValue}>
|
/>, { context: { network: {
|
||||||
<_OrganizationEdit
|
api,
|
||||||
organization={mockData}
|
handleHttpError: () => {}
|
||||||
api={api}
|
} } }
|
||||||
handleHttpError={() => {}}
|
|
||||||
/>
|
|
||||||
</NetworkProvider>
|
|
||||||
</I18nProvider>
|
|
||||||
</MemoryRouter>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const updatedOrgData = {
|
const updatedOrgData = {
|
||||||
@@ -66,18 +51,13 @@ describe('<OrganizationEdit />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('handleSubmit associates and disassociates instance groups', async () => {
|
test('handleSubmit associates and disassociates instance groups', async () => {
|
||||||
const wrapper = mount(
|
const wrapper = mountWithContexts(
|
||||||
<MemoryRouter>
|
<OrganizationEdit
|
||||||
<I18nProvider>
|
organization={mockData}
|
||||||
<NetworkProvider value={networkProviderValue}>
|
/>, { context: { network: {
|
||||||
<_OrganizationEdit
|
api,
|
||||||
organization={mockData}
|
handleHttpError: () => {}
|
||||||
api={api}
|
} } }
|
||||||
handleHttpError={() => {}}
|
|
||||||
/>
|
|
||||||
</NetworkProvider>
|
|
||||||
</I18nProvider>
|
|
||||||
</MemoryRouter>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const updatedOrgData = {
|
const updatedOrgData = {
|
||||||
@@ -106,19 +86,16 @@ describe('<OrganizationEdit />', () => {
|
|||||||
const history = {
|
const history = {
|
||||||
push: jest.fn(),
|
push: jest.fn(),
|
||||||
};
|
};
|
||||||
const wrapper = mount(
|
const wrapper = mountWithContexts(
|
||||||
<MemoryRouter>
|
<OrganizationEdit
|
||||||
<I18nProvider>
|
organization={mockData}
|
||||||
<NetworkProvider value={networkProviderValue}>
|
/>, { context: {
|
||||||
<_OrganizationEdit
|
network: {
|
||||||
organization={mockData}
|
api: { api },
|
||||||
api={api}
|
handleHttpError: () => {}
|
||||||
handleHttpError={() => {}}
|
},
|
||||||
history={history}
|
router: { history }
|
||||||
/>
|
} }
|
||||||
</NetworkProvider>
|
|
||||||
</I18nProvider>
|
|
||||||
</MemoryRouter>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(history.push).not.toHaveBeenCalled();
|
expect(history.push).not.toHaveBeenCalled();
|
||||||
|
|||||||
@@ -1,60 +1,45 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mountWithContexts } from '../../../../enzymeHelpers';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
|
||||||
import { _OrganizationNotifications } from '../../../../../src/pages/Organizations/screens/Organization/OrganizationNotifications';
|
import OrganizationNotifications from '../../../../../src/pages/Organizations/screens/Organization/OrganizationNotifications';
|
||||||
|
|
||||||
describe('<OrganizationNotifications />', () => {
|
describe('<OrganizationNotifications />', () => {
|
||||||
|
let api;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
api = {
|
||||||
|
getOrganizationNotifications: jest.fn(),
|
||||||
|
getOrganizationNotificationSuccess: jest.fn(),
|
||||||
|
getOrganizationNotificationError: jest.fn(),
|
||||||
|
createOrganizationNotificationSuccess: jest.fn(),
|
||||||
|
createOrganizationNotificationError: jest.fn()
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mountWithContexts(
|
||||||
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
<OrganizationNotifications />, { context: { network: {
|
||||||
<_OrganizationNotifications
|
api,
|
||||||
match={{ path: '/organizations/:id/notifications', url: '/organizations/1/notifications' }}
|
handleHttpError: () => {}
|
||||||
location={{ search: '', pathname: '/organizations/1/notifications' }}
|
} } }
|
||||||
params={{}}
|
|
||||||
api={{
|
|
||||||
getOrganizationNotifications: jest.fn(),
|
|
||||||
getOrganizationNotificationSuccess: jest.fn(),
|
|
||||||
getOrganizationNotificationError: jest.fn(),
|
|
||||||
createOrganizationNotificationSuccess: jest.fn(),
|
|
||||||
createOrganizationNotificationError: jest.fn()
|
|
||||||
}}
|
|
||||||
handleHttpError={() => {}}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
test('handles api requests', () => {
|
test('handles api requests', () => {
|
||||||
const getOrganizationNotifications = jest.fn();
|
const wrapper = mountWithContexts(
|
||||||
const getOrganizationNotificationSuccess = jest.fn();
|
<OrganizationNotifications />, { context: { network: {
|
||||||
const getOrganizationNotificationError = jest.fn();
|
api,
|
||||||
const createOrganizationNotificationSuccess = jest.fn();
|
handleHttpError: () => {}
|
||||||
const createOrganizationNotificationError = jest.fn();
|
} } }
|
||||||
const wrapper = mount(
|
|
||||||
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
|
||||||
<_OrganizationNotifications
|
|
||||||
match={{ path: '/organizations/:id/notifications', url: '/organizations/1/notifications' }}
|
|
||||||
location={{ search: '', pathname: '/organizations/1/notifications' }}
|
|
||||||
params={{}}
|
|
||||||
api={{
|
|
||||||
getOrganizationNotifications,
|
|
||||||
getOrganizationNotificationSuccess,
|
|
||||||
getOrganizationNotificationError,
|
|
||||||
createOrganizationNotificationSuccess,
|
|
||||||
createOrganizationNotificationError
|
|
||||||
}}
|
|
||||||
handleHttpError={() => {}}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
).find('OrganizationNotifications');
|
).find('OrganizationNotifications');
|
||||||
wrapper.instance().readOrgNotifications(1, { foo: 'bar' });
|
wrapper.instance().readOrgNotifications(1, { foo: 'bar' });
|
||||||
expect(getOrganizationNotifications).toHaveBeenCalledWith(1, { foo: 'bar' });
|
expect(api.getOrganizationNotifications).toHaveBeenCalledWith(1, { foo: 'bar' });
|
||||||
wrapper.instance().readOrgNotificationSuccess(1, { foo: 'bar' });
|
wrapper.instance().readOrgNotificationSuccess(1, { foo: 'bar' });
|
||||||
expect(getOrganizationNotificationSuccess).toHaveBeenCalledWith(1, { foo: 'bar' });
|
expect(api.getOrganizationNotificationSuccess).toHaveBeenCalledWith(1, { foo: 'bar' });
|
||||||
wrapper.instance().readOrgNotificationError(1, { foo: 'bar' });
|
wrapper.instance().readOrgNotificationError(1, { foo: 'bar' });
|
||||||
expect(getOrganizationNotificationError).toHaveBeenCalledWith(1, { foo: 'bar' });
|
expect(api.getOrganizationNotificationError).toHaveBeenCalledWith(1, { foo: 'bar' });
|
||||||
wrapper.instance().createOrgNotificationSuccess(1, { id: 2 });
|
wrapper.instance().createOrgNotificationSuccess(1, { id: 2 });
|
||||||
expect(createOrganizationNotificationSuccess).toHaveBeenCalledWith(1, { id: 2 });
|
expect(api.createOrganizationNotificationSuccess).toHaveBeenCalledWith(1, { id: 2 });
|
||||||
wrapper.instance().createOrgNotificationError(1, { id: 2 });
|
wrapper.instance().createOrgNotificationError(1, { id: 2 });
|
||||||
expect(createOrganizationNotificationError).toHaveBeenCalledWith(1, { id: 2 });
|
expect(api.createOrganizationNotificationError).toHaveBeenCalledWith(1, { id: 2 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount, shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import { MemoryRouter, Router } from 'react-router-dom';
|
|
||||||
import { I18nProvider } from '@lingui/react';
|
|
||||||
import { createMemoryHistory } from 'history';
|
import { createMemoryHistory } from 'history';
|
||||||
|
import { mountWithContexts } from '../../../../enzymeHelpers';
|
||||||
import { sleep } from '../../../../testUtils';
|
import { sleep } from '../../../../testUtils';
|
||||||
import OrganizationTeams, { _OrganizationTeams } from '../../../../../src/pages/Organizations/screens/Organization/OrganizationTeams';
|
import OrganizationTeams, { _OrganizationTeams } from '../../../../../src/pages/Organizations/screens/Organization/OrganizationTeams';
|
||||||
import OrganizationTeamsList from '../../../../../src/pages/Organizations/components/OrganizationTeamsList';
|
import OrganizationTeamsList from '../../../../../src/pages/Organizations/components/OrganizationTeamsList';
|
||||||
import { NetworkProvider } from '../../../../../src/contexts/Network';
|
|
||||||
|
|
||||||
const listData = {
|
const listData = {
|
||||||
data: {
|
data: {
|
||||||
@@ -38,19 +36,13 @@ describe('<OrganizationTeams />', () => {
|
|||||||
|
|
||||||
test('should load teams on mount', () => {
|
test('should load teams on mount', () => {
|
||||||
const readOrganizationTeamsList = jest.fn(() => Promise.resolve(listData));
|
const readOrganizationTeamsList = jest.fn(() => Promise.resolve(listData));
|
||||||
mount(
|
mountWithContexts(
|
||||||
<I18nProvider>
|
<OrganizationTeams
|
||||||
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
id={1}
|
||||||
<NetworkProvider
|
searchString=""
|
||||||
value={{ api: { readOrganizationTeamsList }, handleHttpError: () => {} }}
|
/>, { context: {
|
||||||
>
|
network: { api: { readOrganizationTeamsList }, handleHttpError: () => {} } }
|
||||||
<OrganizationTeams
|
}
|
||||||
id={1}
|
|
||||||
searchString=""
|
|
||||||
/>
|
|
||||||
</NetworkProvider>
|
|
||||||
</MemoryRouter>
|
|
||||||
</I18nProvider>
|
|
||||||
).find('OrganizationTeams');
|
).find('OrganizationTeams');
|
||||||
expect(readOrganizationTeamsList).toHaveBeenCalledWith(1, {
|
expect(readOrganizationTeamsList).toHaveBeenCalledWith(1, {
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -61,19 +53,13 @@ describe('<OrganizationTeams />', () => {
|
|||||||
|
|
||||||
test('should pass fetched teams to list component', async () => {
|
test('should pass fetched teams to list component', async () => {
|
||||||
const readOrganizationTeamsList = jest.fn(() => Promise.resolve(listData));
|
const readOrganizationTeamsList = jest.fn(() => Promise.resolve(listData));
|
||||||
const wrapper = mount(
|
const wrapper = mountWithContexts(
|
||||||
<I18nProvider>
|
<OrganizationTeams
|
||||||
<MemoryRouter>
|
id={1}
|
||||||
<NetworkProvider
|
searchString=""
|
||||||
value={{ api: { readOrganizationTeamsList }, handleHttpError: () => {} }}
|
/>, { context: {
|
||||||
>
|
network: { api: { readOrganizationTeamsList }, handleHttpError: () => {} } }
|
||||||
<OrganizationTeams
|
}
|
||||||
id={1}
|
|
||||||
searchString=""
|
|
||||||
/>
|
|
||||||
</NetworkProvider>
|
|
||||||
</MemoryRouter>
|
|
||||||
</I18nProvider>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
@@ -105,19 +91,14 @@ describe('<OrganizationTeams />', () => {
|
|||||||
const history = createMemoryHistory({
|
const history = createMemoryHistory({
|
||||||
initialEntries: ['/organizations/1/teams'],
|
initialEntries: ['/organizations/1/teams'],
|
||||||
});
|
});
|
||||||
const wrapper = mount(
|
const wrapper = mountWithContexts(
|
||||||
<Router history={history}>
|
<OrganizationTeams
|
||||||
<I18nProvider>
|
id={1}
|
||||||
<NetworkProvider
|
searchString=""
|
||||||
value={{ api: { readOrganizationTeamsList }, handleHttpError: () => {} }}
|
/>, { context: {
|
||||||
>
|
network: { api: { readOrganizationTeamsList }, handleHttpError: () => {} },
|
||||||
<OrganizationTeams
|
router: { history }
|
||||||
id={1}
|
} }
|
||||||
searchString=""
|
|
||||||
/>
|
|
||||||
</NetworkProvider>
|
|
||||||
</I18nProvider>
|
|
||||||
</Router>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
@@ -132,7 +113,6 @@ describe('<OrganizationTeams />', () => {
|
|||||||
|
|
||||||
readOrganizationTeamsList.mockReturnValueOnce(page2Data);
|
readOrganizationTeamsList.mockReturnValueOnce(page2Data);
|
||||||
history.push('/organizations/1/teams?page=2');
|
history.push('/organizations/1/teams?page=2');
|
||||||
wrapper.setProps({ history });
|
|
||||||
|
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import React, {
|
|||||||
Fragment
|
Fragment
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { withRouter } from 'react-router-dom';
|
||||||
import { Title, EmptyState, EmptyStateIcon, EmptyStateBody } from '@patternfly/react-core';
|
import { Title, EmptyState, EmptyStateIcon, EmptyStateBody } from '@patternfly/react-core';
|
||||||
import { CubesIcon } from '@patternfly/react-icons';
|
import { CubesIcon } from '@patternfly/react-icons';
|
||||||
import { I18n, i18nMark } from '@lingui/react';
|
import { I18n, i18nMark } from '@lingui/react';
|
||||||
@@ -344,4 +345,4 @@ Notifications.propTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export { Notifications as _Notifications };
|
export { Notifications as _Notifications };
|
||||||
export default withNetwork(Notifications);
|
export default withRouter(withNetwork(Notifications));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link, withRouter } from 'react-router-dom';
|
||||||
import { I18n } from '@lingui/react';
|
import { I18n } from '@lingui/react';
|
||||||
import { Trans, t } from '@lingui/macro';
|
import { Trans, t } from '@lingui/macro';
|
||||||
|
|
||||||
@@ -178,4 +178,4 @@ class OrganizationDetail extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withNetwork(OrganizationDetail);
|
export default withRouter(withNetwork(OrganizationDetail));
|
||||||
|
|||||||
@@ -41,12 +41,6 @@ class OrganizationNotifications extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const {
|
|
||||||
location,
|
|
||||||
match,
|
|
||||||
history
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NotificationsList
|
<NotificationsList
|
||||||
onReadNotifications={this.readOrgNotifications}
|
onReadNotifications={this.readOrgNotifications}
|
||||||
@@ -54,9 +48,6 @@ class OrganizationNotifications extends Component {
|
|||||||
onReadError={this.readOrgNotificationError}
|
onReadError={this.readOrgNotificationError}
|
||||||
onCreateSuccess={this.createOrgNotificationSuccess}
|
onCreateSuccess={this.createOrgNotificationSuccess}
|
||||||
onCreateError={this.createOrgNotificationError}
|
onCreateError={this.createOrgNotificationError}
|
||||||
match={match}
|
|
||||||
location={location}
|
|
||||||
history={history}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user