mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
working test commit
This commit is contained in:
parent
aab6aa4ef9
commit
3a8d95b03b
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 { mount } from 'enzyme';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import OrganizationBreadcrumb from '../../../../src/pages/Organizations/components/OrganizationBreadcrumb';
|
||||
|
||||
xdescribe('<OrganizationBreadcrumb />', () => {
|
||||
describe('<OrganizationBreadcrumb />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
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 { mount } from 'enzyme';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import OrganizationDetail from '../../../../src/pages/Organizations/components/OrganizationDetail';
|
||||
|
||||
xdescribe('<OrganizationDetail />', () => {
|
||||
describe('<OrganizationDetail />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
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 { mount } from 'enzyme';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import OrganizationEdit from '../../../../src/pages/Organizations/components/OrganizationEdit';
|
||||
|
||||
xdescribe('<OrganizationEdit />', () => {
|
||||
describe('<OrganizationEdit />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
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 { mount } from 'enzyme';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import OrganizationListItem from '../../../../src/pages/Organizations/components/OrganizationListItem';
|
||||
|
||||
xdescribe('<OrganizationListItem />', () => {
|
||||
describe('<OrganizationListItem />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<OrganizationListItem />
|
||||
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
||||
<OrganizationListItem />
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -8,7 +8,7 @@ describe('<Organizations />', () => {
|
||||
mount(
|
||||
<MemoryRouter initialEntries={['/organizations']} initialIndex={0}>
|
||||
<Organizations
|
||||
match={{ path: '/organizations', route: '/organizations', link: 'organizations' }}
|
||||
match={{ path: '/organizations', url: '/organizations' }}
|
||||
location={{ search: '', pathname: '/organizations' }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
|
||||
@ -2,10 +2,13 @@ import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import OrganizationAdd from '../../../../src/pages/Organizations/views/Organization.add';
|
||||
|
||||
xdescribe('<OrganizationAdd />', () => {
|
||||
describe('<OrganizationAdd />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<OrganizationAdd />
|
||||
<OrganizationAdd
|
||||
match={{ path: '/organizations/add', url: '/organizations/add' }}
|
||||
location={{ search: '', pathname: '/organizations/add' }}
|
||||
/>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,11 +1,17 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import OrganizationView from '../../../../src/pages/Organizations/views/Organization.view';
|
||||
|
||||
xdescribe('<OrganizationView />', () => {
|
||||
describe('<OrganizationView />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
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 { mount } from 'enzyme';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import OrganizationsList from '../../../../src/pages/Organizations/views/Organizations.list';
|
||||
|
||||
xdescribe('<OrganizationsList />', () => {
|
||||
describe('<OrganizationsList />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
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 {
|
||||
transforms = {
|
||||
top: {
|
||||
bottom: "100%",
|
||||
left: "50%",
|
||||
transform: "translate(-50%, -25%)"
|
||||
bottom: '100%',
|
||||
left: '50%',
|
||||
transform: 'translate(-50%, -25%)'
|
||||
},
|
||||
bottom: {
|
||||
top: "100%",
|
||||
left: "50%",
|
||||
transform: "translate(-50%, 25%)"
|
||||
top: '100%',
|
||||
left: '50%',
|
||||
transform: 'translate(-50%, 25%)'
|
||||
},
|
||||
left: {
|
||||
top: "50%",
|
||||
right: "100%",
|
||||
transform: "translate(-25%, -50%)"
|
||||
top: '50%',
|
||||
right: '100%',
|
||||
transform: 'translate(-25%, -50%)'
|
||||
},
|
||||
right: {
|
||||
bottom: "100%",
|
||||
left: "50%",
|
||||
transform: "translate(25%, 50%)"
|
||||
bottom: '100%',
|
||||
left: '50%',
|
||||
transform: 'translate(25%, 50%)'
|
||||
},
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
constructor (props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
isDisplayed: false
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
render () {
|
||||
const {
|
||||
children,
|
||||
message,
|
||||
@ -44,24 +44,30 @@ class Tooltip extends React.Component {
|
||||
|
||||
return (
|
||||
<span
|
||||
style={{ position: "relative"}}
|
||||
onMouseLeave={() => this.setState({ isDisplayed: false })}>
|
||||
{ isDisplayed &&
|
||||
<div
|
||||
style={{ position: "absolute", zIndex: "10", ...this.transforms[position] }}
|
||||
className={`pf-c-tooltip pf-m-${position}`}>
|
||||
<div className="pf-c-tooltip__arrow"></div>
|
||||
<div className="pf-c-tooltip__content">
|
||||
{ message }
|
||||
style={{ position: 'relative' }}
|
||||
onMouseLeave={() => this.setState({ isDisplayed: false })}
|
||||
>
|
||||
{ isDisplayed
|
||||
&& (
|
||||
<div
|
||||
style={{ position: 'absolute', zIndex: '10', ...this.transforms[position] }}
|
||||
className={`pf-c-tooltip pf-m-${position}`}
|
||||
>
|
||||
<div className="pf-c-tooltip__arrow" />
|
||||
<div className="pf-c-tooltip__content">
|
||||
{ message }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<span
|
||||
onMouseOver={() => this.setState({ isDisplayed: true })}>
|
||||
onMouseOver={() => this.setState({ isDisplayed: true })}
|
||||
onFocus={() => this.setState({ isDisplayed: true })}
|
||||
>
|
||||
{ children }
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user