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/74077/ts migration of account limits footer portal and tests #66

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AccountLimitsFooterPortal from '../account-limits-footer';
const AccountLimitsFooterPortalComponent = () => (
<AccountLimitsContext.Provider
value={{
footer_ref: <div data-testid='mocked_footer_ref'></div>,
footer_ref: <div data-testid='mocked_footer_ref' />,
toggleOverlay: jest.fn(),
}}
>
Expand All @@ -17,13 +17,13 @@ const AccountLimitsFooterPortalComponent = () => (

describe('<AccountLimitsFooterPortal/>', () => {
beforeAll(() => {
ReactDOM.createPortal = jest.fn(component => {
(ReactDOM.createPortal as jest.Mock) = jest.fn(component => {
return component;
});
});

afterAll(() => {
ReactDOM.createPortal.mockClear();
(ReactDOM.createPortal as jest.Mock).mockClear();
});

it('should render AccountLimitsFooterPortal component', () => {
Expand All @@ -36,7 +36,7 @@ describe('<AccountLimitsFooterPortal/>', () => {
});

it('should render AppSettings.Footer components correctly', () => {
const { container } = render(<AccountLimitsFooterPortalComponent />);
expect(container.getElementsByClassName('dc-app-settings__footer').length).toBe(1);
render(<AccountLimitsFooterPortalComponent />);
expect(screen.queryByTestId('dt_app_settings_footer')).toHaveTextContent('Learn more about account limits');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jest.mock('@deriv/shared', () => ({

jest.mock('Components/demo-message', () => jest.fn(() => 'mockedDemoMessage'));
jest.mock('Components/load-error-message', () => jest.fn(() => 'mockedLoadErrorMessage'));
jest.mock('../account-limits-footer.jsx', () => jest.fn(() => 'mockedAccountLimitsFooter'));
jest.mock('../account-limits-footer', () => jest.fn(() => 'mockedAccountLimitsFooter'));

describe('<AccountLimits/>', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 AccountLimitsFooter from './account-limits-footer.jsx';
import AccountLimitsFooter from './account-limits-footer';
import AccountLimitsOverlay from './account-limits-overlay.jsx';
import AccountLimitsTableCell from './account-limits-table-cell.jsx';
import AccountLimitsTableHeader from './account-limits-table-header.jsx';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import * as React from 'react';

const AppSettingsFooter = ({ children }) => <div className='dc-app-settings__footer'>{children}</div>;
const AppSettingsFooter = ({ children }) => (
<div data-testid='dt_app_settings_footer' className='dc-app-settings__footer'>
{children}
</div>
);
const AppSettingsFooterLeft = ({ children }) => <div className='dc-app-settings__footer-left'>{children}</div>;
const AppSettingsFooterRight = ({ children }) => <div className='dc-app-settings__footer-right'>{children}</div>;

Expand Down