Closed jindrichkuba closed 5 years ago
import React from 'react';
import PropTypes from 'prop-types';
import { formatValueObject } from 'helpers/ValueFormatter';
import { ValuePropType, CockpitIconColor } from 'types';
import { WidgetTitle } from 'cockpit/components';
import './_Circle.scss';
export const Circle = ({ data: { ComparatorValueObject, IconColor, Title, Description, ValueObject, MarginPYValue, MarginSPValue }, isThousands }) => {
const mainValue = formatValueObject(ValueObject, isThousands);
const subValue = formatValueObject(ComparatorValueObject, isThousands);
return (
<div className="Circle">
<WidgetTitle IconColor={IconColor}>{Title} lol</WidgetTitle>
<div className="Circle-ellipse">
<div className="Circle-outline">
<div className="Circle-midline">
<div className="Circle-inline" />
</div>
</div>
<div className="Circle-label">{Description}</div>
<div className={`Circle-title ${mainValue.length >= 8 ? 'Circle-title--small' : ''}`}>{mainValue}</div>
<div className="Circle-description">{subValue}</div>
</div>
{MarginPYValue && MarginSPValue && (
<div className="Circle-margin">
<div className="Circle-margin--description">Margin:</div>
<div className="Circle-margin--numbers">
{formatValueObject(MarginPYValue, isThousands)} <br /> {formatValueObject(MarginSPValue, isThousands)}
</div>
</div>
)}
</div>
);
};
import React from 'react';
import { shallow } from 'enzyme';
import { Circle } from '../Circle';
it('renders without crashing', () => {
shallow(
<Circle
isThousands={false}
/>
);
});
The issue is Jest are going inside /components and there are also components connected with Redux, I will separate those components to container components by article https://daveceddia.com/react-project-structure/
But if someone found different solution, let me know.. thank you, have a nice day
When I removed WidgetTitle or I changed path to normal component, test will be ok, anyone know how to fix it? I would like to use only absolute path.