Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suisin/74076/ts migration for account limits extra info and tests #68

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { screen, render } from '@testing-library/react';
import { isMobile } from '@deriv/shared';
import AccountLimitsExtraInfo from '../account-limits-extra-info';

jest.mock('@deriv/shared', () => ({
...jest.requireActual('@deriv/shared'),
isMobile: jest.fn(() => true),
}));

describe('<AccountLimitsExtraInfo/>', () => {
it('should render AccountLimitsExtraInfo component', () => {
render(<AccountLimitsExtraInfo message='Lorem ipsum' />);
expect(screen.getByText(/lorem ipsum/i)).toBeInTheDocument();
});

it('should render PopoverComponent if isMobile is false', () => {
(isMobile as jest.Mock).mockReturnValue(false);
render(<AccountLimitsExtraInfo message='Lorem ipsum' />);
expect(screen.queryByTestId('dt_acc_limits_popover')).toHaveClass('da-account-limits__popover');
});

it('should pass props to PopoverComponent if isMobile is false', async () => {
(isMobile as jest.Mock).mockReturnValue(false);
render(<AccountLimitsExtraInfo message='Lorem ipsum' className='test_class' />);
const popover = await screen.findByTestId('dt_acc_limits_popover');
expect(popover).toHaveClass('test_class');
});
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import PropTypes from 'prop-types';
import * as React from 'react';
import { Popover, Text } from '@deriv/components';
import { isMobile } from '@deriv/shared';

const AccountLimitsExtraInfo = ({ message, ...props }) => {
type TAccountLimitsExtraInfo = {
message: string;
className?: string;
};

const AccountLimitsExtraInfo = ({ message, ...props }: TAccountLimitsExtraInfo) => {
if (isMobile()) {
return (
<Text color='less-prominent' line_height='s' size='xxxs'>
Expand All @@ -14,6 +18,7 @@ const AccountLimitsExtraInfo = ({ message, ...props }) => {

return (
<Popover
data_testid='dt_acc_limits_popover'
alignment='right'
className='da-account-limits__popover'
icon='info'
Expand All @@ -25,8 +30,4 @@ const AccountLimitsExtraInfo = ({ message, ...props }) => {
);
};

AccountLimitsExtraInfo.propTypes = {
message: PropTypes.string.isRequired,
};

export default AccountLimitsExtraInfo;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import LoadErrorMessage from 'Components/load-error-message';
import DemoMessage from 'Components/demo-message';
import AccountLimitsArticle from './account-limits-article.jsx';
import AccountLimitsContext from './account-limits-context';
import AccountLimitsExtraInfo from './account-limits-extra-info.jsx';
import AccountLimitsExtraInfo from './account-limits-extra-info';
import AccountLimitsFooter from './account-limits-footer.jsx';
import AccountLimitsOverlay from './account-limits-overlay.jsx';
import AccountLimitsTableCell from './account-limits-table-cell.jsx';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/components/popover/popover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Popover = ({
should_show_cursor,
window_border,
zIndex,
data_testid,
}) => {
const ref = React.useRef();
const [popover_ref, setPopoverRef] = React.useState(undefined);
Expand Down Expand Up @@ -169,7 +170,7 @@ const Popover = ({
);
}}
>
<div className={classNames('dc-popover', className)} id={id}>
<div data-testid={data_testid} className={classNames('dc-popover', className)} id={id}>
<div className={classNames(classNameTarget, 'dc-popover__target')}>
{!disable_target_icon && (
<i
Expand Down