mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
working commit tests
This commit is contained in:
parent
12c8267b12
commit
aab6aa4ef9
@ -4,8 +4,6 @@ import DataListToolbar from '../../src/components/DataListToolbar';
|
||||
|
||||
describe('<DataListToolbar />', () => {
|
||||
const columns = [{ name: 'Name', key: 'name', isSortable: true }];
|
||||
const noop = () => {};
|
||||
|
||||
let toolbar;
|
||||
|
||||
afterEach(() => {
|
||||
|
@ -1,24 +0,0 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { API_ORGANIZATIONS } from '../../../src/endpoints';
|
||||
import OrganizationAdd from '../../../src/pages/Organizations/Organization.add';
|
||||
|
||||
describe('<OrganizationAdd />', () => {
|
||||
let pageWrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
pageWrapper = mount(<OrganizationAdd />);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
pageWrapper.unmount();
|
||||
});
|
||||
|
||||
test('initially renders without crashing', () => {
|
||||
expect(pageWrapper.length).toBe(1);
|
||||
});
|
||||
|
||||
test('API Organization endpoint is valid', () => {
|
||||
expect(API_ORGANIZATIONS).toBeDefined();
|
||||
});
|
||||
});
|
@ -1,32 +0,0 @@
|
||||
import React from 'react';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { mount } from 'enzyme';
|
||||
import { API_ORGANIZATIONS } from '../../../src/endpoints';
|
||||
import OrganizationView from '../../../src/pages/Organizations/Organization.view';
|
||||
|
||||
describe('<OrganizationView />', () => {
|
||||
let pageWrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
pageWrapper = mount(
|
||||
<MemoryRouter initialEntries={['/organizations/1']}>
|
||||
<OrganizationView
|
||||
match={{ path: '/organizations/:id', route: 'organizations/1', link: 'organizations', params: { id: '1' } }}
|
||||
location={{ search: '', pathname: '' }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
pageWrapper.unmount();
|
||||
});
|
||||
|
||||
test('initially renders without crashing', () => {
|
||||
expect(pageWrapper.length).toBe(1);
|
||||
});
|
||||
|
||||
test('API Organization endpoint is valid', () => {
|
||||
expect(API_ORGANIZATIONS).toBeDefined();
|
||||
});
|
||||
});
|
@ -1,90 +0,0 @@
|
||||
import React from 'react';
|
||||
import { HashRouter } from 'react-router-dom';
|
||||
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import api from '../../../src/api';
|
||||
import { API_ORGANIZATIONS } from '../../../src/endpoints';
|
||||
import Organizations from '../../../src/pages/Organizations';
|
||||
|
||||
describe('<Organizations />', () => {
|
||||
let pageWrapper;
|
||||
|
||||
const results = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'org 1',
|
||||
summary_fields: {
|
||||
related_field_counts: {
|
||||
users: 1,
|
||||
teams: 1,
|
||||
admins: 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'org 2',
|
||||
summary_fields: {
|
||||
related_field_counts: {
|
||||
users: 1,
|
||||
teams: 1,
|
||||
admins: 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'org 3',
|
||||
summary_fields: {
|
||||
related_field_counts: {
|
||||
users: 1,
|
||||
teams: 1,
|
||||
admins: 1
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
const count = results.length;
|
||||
const response = { data: { count, results } };
|
||||
|
||||
beforeEach(() => {
|
||||
api.get = jest.fn().mockImplementation(() => Promise.resolve(response));
|
||||
pageWrapper = mount(<HashRouter><Organizations /></HashRouter>);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
pageWrapper.unmount();
|
||||
});
|
||||
|
||||
test('it renders expected content', () => {
|
||||
const pageSections = pageWrapper.find('PageSection');
|
||||
const title = pageWrapper.find('Title');
|
||||
|
||||
expect(pageWrapper.length).toBe(1);
|
||||
expect(pageSections.length).toBe(2);
|
||||
expect(title.length).toBe(1);
|
||||
expect(title.props().size).toBe('2xl');
|
||||
pageSections.forEach(section => {
|
||||
expect(section.props().variant).toBeDefined();
|
||||
});
|
||||
expect(pageWrapper.find('ul').length).toBe(1);
|
||||
expect(pageWrapper.find('ul li').length).toBe(0);
|
||||
// will render all list items on update
|
||||
pageWrapper.update();
|
||||
expect(pageWrapper.find('ul li').length).toBe(count);
|
||||
});
|
||||
|
||||
test('API Organization endpoint is valid', () => {
|
||||
expect(API_ORGANIZATIONS).toBeDefined();
|
||||
});
|
||||
|
||||
test('it displays a tooltip on delete hover', () => {
|
||||
const tooltip = '.pf-c-tooltip__content';
|
||||
const deleteButton = 'button[aria-label="Delete"]';
|
||||
|
||||
expect(pageWrapper.find(tooltip).length).toBe(0);
|
||||
pageWrapper.find(deleteButton).simulate('mouseover');
|
||||
expect(pageWrapper.find(tooltip).length).toBe(1);
|
||||
});
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import OrganizationBreadcrumb from '../../../../src/pages/Organizations/components/OrganizationBreadcrumb';
|
||||
|
||||
xdescribe('<OrganizationBreadcrumb />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<OrganizationBreadcrumb />
|
||||
);
|
||||
});
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import OrganizationDetail from '../../../../src/pages/Organizations/components/OrganizationDetail';
|
||||
|
||||
xdescribe('<OrganizationDetail />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<OrganizationDetail />
|
||||
);
|
||||
});
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import OrganizationEdit from '../../../../src/pages/Organizations/components/OrganizationEdit';
|
||||
|
||||
xdescribe('<OrganizationEdit />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<OrganizationEdit />
|
||||
);
|
||||
});
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import OrganizationListItem from '../../../../src/pages/Organizations/components/OrganizationListItem';
|
||||
|
||||
xdescribe('<OrganizationListItem />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<OrganizationListItem />
|
||||
);
|
||||
});
|
||||
});
|
17
__tests__/pages/Organizations/index.test.jsx
Normal file
17
__tests__/pages/Organizations/index.test.jsx
Normal file
@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { mount } from 'enzyme';
|
||||
import Organizations from '../../../src/pages/Organizations/index';
|
||||
|
||||
describe('<Organizations />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
||||
<Organizations
|
||||
match={{ path: '/organizations', route: '/organizations', link: 'organizations' }}
|
||||
location={{ search: '', pathname: '/organizations' }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
});
|
13
__tests__/pages/Organizations/utils.test.jsx
Normal file
13
__tests__/pages/Organizations/utils.test.jsx
Normal file
@ -0,0 +1,13 @@
|
||||
import getTabName from '../../../src/pages/Organizations/utils';
|
||||
|
||||
describe('getTabName', () => {
|
||||
test('returns tab name', () => {
|
||||
expect(getTabName('details')).toBe('Details');
|
||||
expect(getTabName('users')).toBe('Users');
|
||||
expect(getTabName('teams')).toBe('Teams');
|
||||
expect(getTabName('admins')).toBe('Admins');
|
||||
expect(getTabName('notifications')).toBe('Notifications');
|
||||
expect(getTabName('unknown')).toBe('');
|
||||
expect(getTabName()).toBe('');
|
||||
});
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import OrganizationAdd from '../../../../src/pages/Organizations/views/Organization.add';
|
||||
|
||||
xdescribe('<OrganizationAdd />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<OrganizationAdd />
|
||||
);
|
||||
});
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import OrganizationView from '../../../../src/pages/Organizations/views/Organization.view';
|
||||
|
||||
xdescribe('<OrganizationView />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<OrganizationView />
|
||||
);
|
||||
});
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import OrganizationsList from '../../../../src/pages/Organizations/views/Organizations.list';
|
||||
|
||||
xdescribe('<OrganizationsList />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<OrganizationsList />
|
||||
);
|
||||
});
|
||||
});
|
@ -5,7 +5,7 @@
|
||||
"main": "index.jsx",
|
||||
"scripts": {
|
||||
"start": "webpack-dev-server --config ./webpack.config.js --mode development",
|
||||
"test": "jest --watchAll --coverage",
|
||||
"test": "jest --watch --coverage",
|
||||
"lint": "./node_modules/eslint/bin/eslint.js src/**/*.js src/**/*.jsx"
|
||||
},
|
||||
"keywords": [],
|
||||
|
Loading…
Reference in New Issue
Block a user