mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 05:45:02 -02:30
working test commit
This commit is contained in:
12
__tests__/components/Tooltip.test.jsx
Normal file
12
__tests__/components/Tooltip.test.jsx
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { mount } from 'enzyme';
|
||||||
|
import Tooltip from '../../src/components/Tooltip';
|
||||||
|
|
||||||
|
describe('<Tooltip />', () => {
|
||||||
|
let wrapper;
|
||||||
|
|
||||||
|
test('initially renders without crashing', () => {
|
||||||
|
wrapper = mount(<Tooltip />);
|
||||||
|
expect(wrapper.length).toBe(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import OrganizationBreadcrumb from '../../../../src/pages/Organizations/components/OrganizationBreadcrumb';
|
import OrganizationBreadcrumb from '../../../../src/pages/Organizations/components/OrganizationBreadcrumb';
|
||||||
|
|
||||||
xdescribe('<OrganizationBreadcrumb />', () => {
|
describe('<OrganizationBreadcrumb />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
<OrganizationBreadcrumb />
|
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
||||||
|
<OrganizationBreadcrumb
|
||||||
|
match={{ path: '/organizations', url: '/organizations' }}
|
||||||
|
location={{ search: '', pathname: '/organizations' }}
|
||||||
|
parentObj={[{ name: 'Organizations', url: '/organizations' }]}
|
||||||
|
/>
|
||||||
|
</MemoryRouter>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import OrganizationDetail from '../../../../src/pages/Organizations/components/OrganizationDetail';
|
import OrganizationDetail from '../../../../src/pages/Organizations/components/OrganizationDetail';
|
||||||
|
|
||||||
xdescribe('<OrganizationDetail />', () => {
|
describe('<OrganizationDetail />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
<OrganizationDetail />
|
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
||||||
|
<OrganizationDetail
|
||||||
|
match={{ path: '/organizations/:id', url: '/organizations/1' }}
|
||||||
|
location={{ search: '', pathname: '/organizations/1' }}
|
||||||
|
/>
|
||||||
|
</MemoryRouter>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import OrganizationEdit from '../../../../src/pages/Organizations/components/OrganizationEdit';
|
import OrganizationEdit from '../../../../src/pages/Organizations/components/OrganizationEdit';
|
||||||
|
|
||||||
xdescribe('<OrganizationEdit />', () => {
|
describe('<OrganizationEdit />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
<OrganizationEdit />
|
<MemoryRouter initialEntries={['/organizations/1/edit']} initialIndex={0}>
|
||||||
|
<OrganizationEdit
|
||||||
|
match={{ path: '/organizations/:id/edit', url: '/organizations/1/edit', params: { id: 1 } }}
|
||||||
|
/>
|
||||||
|
</MemoryRouter>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import OrganizationListItem from '../../../../src/pages/Organizations/components/OrganizationListItem';
|
import OrganizationListItem from '../../../../src/pages/Organizations/components/OrganizationListItem';
|
||||||
|
|
||||||
xdescribe('<OrganizationListItem />', () => {
|
describe('<OrganizationListItem />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
<OrganizationListItem />
|
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
||||||
|
<OrganizationListItem />
|
||||||
|
</MemoryRouter>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ describe('<Organizations />', () => {
|
|||||||
mount(
|
mount(
|
||||||
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
||||||
<Organizations
|
<Organizations
|
||||||
match={{ path: '/organizations', route: '/organizations', link: 'organizations' }}
|
match={{ path: '/organizations', url: '/organizations' }}
|
||||||
location={{ search: '', pathname: '/organizations' }}
|
location={{ search: '', pathname: '/organizations' }}
|
||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ import React from 'react';
|
|||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import OrganizationAdd from '../../../../src/pages/Organizations/views/Organization.add';
|
import OrganizationAdd from '../../../../src/pages/Organizations/views/Organization.add';
|
||||||
|
|
||||||
xdescribe('<OrganizationAdd />', () => {
|
describe('<OrganizationAdd />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
<OrganizationAdd />
|
<OrganizationAdd
|
||||||
|
match={{ path: '/organizations/add', url: '/organizations/add' }}
|
||||||
|
location={{ search: '', pathname: '/organizations/add' }}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import OrganizationView from '../../../../src/pages/Organizations/views/Organization.view';
|
import OrganizationView from '../../../../src/pages/Organizations/views/Organization.view';
|
||||||
|
|
||||||
xdescribe('<OrganizationView />', () => {
|
describe('<OrganizationView />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
<OrganizationView />
|
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
||||||
|
<OrganizationView
|
||||||
|
match={{ path: '/organizations/:id', url: '/organizations/1' }}
|
||||||
|
location={{ search: '', pathname: '/organizations/1' }}
|
||||||
|
/>
|
||||||
|
</MemoryRouter>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import OrganizationsList from '../../../../src/pages/Organizations/views/Organizations.list';
|
import OrganizationsList from '../../../../src/pages/Organizations/views/Organizations.list';
|
||||||
|
|
||||||
xdescribe('<OrganizationsList />', () => {
|
describe('<OrganizationsList />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
<OrganizationsList />
|
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
||||||
|
<OrganizationsList
|
||||||
|
match={{ path: '/organizations', url: '/organizations' }}
|
||||||
|
location={{ search: '', pathname: '/organizations' }}
|
||||||
|
/>
|
||||||
|
</MemoryRouter>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,36 +3,36 @@ import React from 'react';
|
|||||||
class Tooltip extends React.Component {
|
class Tooltip extends React.Component {
|
||||||
transforms = {
|
transforms = {
|
||||||
top: {
|
top: {
|
||||||
bottom: "100%",
|
bottom: '100%',
|
||||||
left: "50%",
|
left: '50%',
|
||||||
transform: "translate(-50%, -25%)"
|
transform: 'translate(-50%, -25%)'
|
||||||
},
|
},
|
||||||
bottom: {
|
bottom: {
|
||||||
top: "100%",
|
top: '100%',
|
||||||
left: "50%",
|
left: '50%',
|
||||||
transform: "translate(-50%, 25%)"
|
transform: 'translate(-50%, 25%)'
|
||||||
},
|
},
|
||||||
left: {
|
left: {
|
||||||
top: "50%",
|
top: '50%',
|
||||||
right: "100%",
|
right: '100%',
|
||||||
transform: "translate(-25%, -50%)"
|
transform: 'translate(-25%, -50%)'
|
||||||
},
|
},
|
||||||
right: {
|
right: {
|
||||||
bottom: "100%",
|
bottom: '100%',
|
||||||
left: "50%",
|
left: '50%',
|
||||||
transform: "translate(25%, 50%)"
|
transform: 'translate(25%, 50%)'
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isDisplayed: false
|
isDisplayed: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render () {
|
||||||
const {
|
const {
|
||||||
children,
|
children,
|
||||||
message,
|
message,
|
||||||
@@ -44,24 +44,30 @@ class Tooltip extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
style={{ position: "relative"}}
|
style={{ position: 'relative' }}
|
||||||
onMouseLeave={() => this.setState({ isDisplayed: false })}>
|
onMouseLeave={() => this.setState({ isDisplayed: false })}
|
||||||
{ isDisplayed &&
|
>
|
||||||
<div
|
{ isDisplayed
|
||||||
style={{ position: "absolute", zIndex: "10", ...this.transforms[position] }}
|
&& (
|
||||||
className={`pf-c-tooltip pf-m-${position}`}>
|
<div
|
||||||
<div className="pf-c-tooltip__arrow"></div>
|
style={{ position: 'absolute', zIndex: '10', ...this.transforms[position] }}
|
||||||
<div className="pf-c-tooltip__content">
|
className={`pf-c-tooltip pf-m-${position}`}
|
||||||
{ message }
|
>
|
||||||
|
<div className="pf-c-tooltip__arrow" />
|
||||||
|
<div className="pf-c-tooltip__content">
|
||||||
|
{ message }
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)
|
||||||
}
|
}
|
||||||
<span
|
<span
|
||||||
onMouseOver={() => this.setState({ isDisplayed: true })}>
|
onMouseOver={() => this.setState({ isDisplayed: true })}
|
||||||
|
onFocus={() => this.setState({ isDisplayed: true })}
|
||||||
|
>
|
||||||
{ children }
|
{ children }
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user