mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 03:17:38 -02:30
Move test for AccessList.
This commit is contained in:
@@ -3,7 +3,7 @@ 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 AccessList from '../../src/components/AccessList';
|
import OrganizationAccessList from '../../../../src/pages/Organizations/components/OrganizationAccessList';
|
||||||
|
|
||||||
const mockData = [
|
const mockData = [
|
||||||
{
|
{
|
||||||
@@ -25,12 +25,12 @@ const mockData = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('<AccessList />', () => {
|
describe('<OrganizationAccessList />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<AccessList
|
<OrganizationAccessList
|
||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '1' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '1' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => {}}
|
getAccessList={() => {}}
|
||||||
@@ -45,7 +45,7 @@ describe('<AccessList />', () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<AccessList
|
<OrganizationAccessList
|
||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||||
@@ -53,7 +53,7 @@ describe('<AccessList />', () => {
|
|||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
).find('AccessList');
|
).find('OrganizationAccessList');
|
||||||
|
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
expect(wrapper.state().results).toEqual(mockData);
|
expect(wrapper.state().results).toEqual(mockData);
|
||||||
@@ -62,12 +62,12 @@ describe('<AccessList />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('onExpand and onCompact methods called when user clicks on Expand and Compact icons respectively', async (done) => {
|
test('onExpand and onCompact methods called when user clicks on Expand and Compact icons respectively', async (done) => {
|
||||||
const onExpand = jest.spyOn(AccessList.prototype, 'onExpand');
|
const onExpand = jest.spyOn(OrganizationAccessList.prototype, 'onExpand');
|
||||||
const onCompact = jest.spyOn(AccessList.prototype, 'onCompact');
|
const onCompact = jest.spyOn(OrganizationAccessList.prototype, 'onCompact');
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<AccessList
|
<OrganizationAccessList
|
||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||||
@@ -75,7 +75,7 @@ describe('<AccessList />', () => {
|
|||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
).find('AccessList');
|
).find('OrganizationAccessList');
|
||||||
expect(onExpand).not.toHaveBeenCalled();
|
expect(onExpand).not.toHaveBeenCalled();
|
||||||
expect(onCompact).not.toHaveBeenCalled();
|
expect(onCompact).not.toHaveBeenCalled();
|
||||||
|
|
||||||
@@ -90,11 +90,11 @@ describe('<AccessList />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('onSort being passed properly to DataListToolbar component', async (done) => {
|
test('onSort being passed properly to DataListToolbar component', async (done) => {
|
||||||
const onSort = jest.spyOn(AccessList.prototype, 'onSort');
|
const onSort = jest.spyOn(OrganizationAccessList.prototype, 'onSort');
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<AccessList
|
<OrganizationAccessList
|
||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||||
@@ -102,7 +102,7 @@ describe('<AccessList />', () => {
|
|||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
).find('AccessList');
|
).find('OrganizationAccessList');
|
||||||
expect(onSort).not.toHaveBeenCalled();
|
expect(onSort).not.toHaveBeenCalled();
|
||||||
|
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
@@ -117,7 +117,7 @@ describe('<AccessList />', () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<AccessList
|
<OrganizationAccessList
|
||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||||
@@ -125,7 +125,7 @@ describe('<AccessList />', () => {
|
|||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
).find('AccessList');
|
).find('OrganizationAccessList');
|
||||||
|
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
const { results } = wrapper.state();
|
const { results } = wrapper.state();
|
||||||
@@ -137,13 +137,13 @@ describe('<AccessList />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('test handleWarning, confirmDelete, and removeRole methods for Alert component', (done) => {
|
test('test handleWarning, confirmDelete, and removeRole methods for Alert component', (done) => {
|
||||||
const handleWarning = jest.spyOn(AccessList.prototype, 'handleWarning');
|
const handleWarning = jest.spyOn(OrganizationAccessList.prototype, 'handleWarning');
|
||||||
const confirmDelete = jest.spyOn(AccessList.prototype, 'confirmDelete');
|
const confirmDelete = jest.spyOn(OrganizationAccessList.prototype, 'confirmDelete');
|
||||||
const removeRole = jest.spyOn(AccessList.prototype, 'removeAccessRole');
|
const removeRole = jest.spyOn(OrganizationAccessList.prototype, 'removeAccessRole');
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<AccessList
|
<OrganizationAccessList
|
||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||||
@@ -151,7 +151,7 @@ describe('<AccessList />', () => {
|
|||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
).find('AccessList');
|
).find('OrganizationAccessList');
|
||||||
expect(handleWarning).not.toHaveBeenCalled();
|
expect(handleWarning).not.toHaveBeenCalled();
|
||||||
expect(confirmDelete).not.toHaveBeenCalled();
|
expect(confirmDelete).not.toHaveBeenCalled();
|
||||||
expect(removeRole).not.toHaveBeenCalled();
|
expect(removeRole).not.toHaveBeenCalled();
|
||||||
@@ -172,7 +172,7 @@ describe('<AccessList />', () => {
|
|||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<AccessList
|
<OrganizationAccessList
|
||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||||
@@ -180,7 +180,7 @@ describe('<AccessList />', () => {
|
|||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
).find('AccessList');
|
).find('OrganizationAccessList');
|
||||||
|
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
const expected = [
|
const expected = [
|
||||||
Reference in New Issue
Block a user