diff --git a/packages/account/src/Components/form-body-section/__tests__/form-body-section.spec.js b/packages/account/src/Components/form-body-section/__tests__/form-body-section.spec.tsx similarity index 76% rename from packages/account/src/Components/form-body-section/__tests__/form-body-section.spec.js rename to packages/account/src/Components/form-body-section/__tests__/form-body-section.spec.tsx index c370e3673767..173c54a4e267 100644 --- a/packages/account/src/Components/form-body-section/__tests__/form-body-section.spec.js +++ b/packages/account/src/Components/form-body-section/__tests__/form-body-section.spec.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { screen, render } from '@testing-library/react'; -import FormBodySection from '../form-body-section'; +import FormBodySection, { TFormBodySection } from '../form-body-section'; -const MockFormBodySection = props => { +const MockFormBodySection = (props: TFormBodySection) => { return (

Lorem Ipsum

@@ -18,7 +18,7 @@ describe('Test coverage for FormBodySection component', () => { it('When we pass "has_side_note" property, it should render a different ui', () => { render(); - expect(screen.getByTestId('side-note-container')).toBeInTheDocument(); + expect(screen.getByTestId('dt_side_note_container')).toBeInTheDocument(); }); it('When "side_note" value is string, it should render inside Text component', () => { @@ -28,9 +28,9 @@ describe('Test coverage for FormBodySection component', () => { }); it('When "side_note" value is not string, it should not render inside Text component', () => { - const test_side_note = 80; + const test_side_note =
test side note component
; render(); - expect(screen.getByText(test_side_note)).toBeInTheDocument(); + expect(screen.getByText('test side note component')).toBeInTheDocument(); expect(screen.queryByTestId('side-note-text')).not.toBeInTheDocument(); }); }); diff --git a/packages/account/src/Components/form-body-section/form-body-section.jsx b/packages/account/src/Components/form-body-section/form-body-section.tsx similarity index 65% rename from packages/account/src/Components/form-body-section/form-body-section.jsx rename to packages/account/src/Components/form-body-section/form-body-section.tsx index 046548957fbf..5c67baa36b47 100644 --- a/packages/account/src/Components/form-body-section/form-body-section.jsx +++ b/packages/account/src/Components/form-body-section/form-body-section.tsx @@ -1,15 +1,20 @@ import React from 'react'; import classNames from 'classnames'; -import { PropTypes } from 'prop-types'; import { Text } from '@deriv/components'; import { PlatformContext } from '@deriv/shared'; +import { TPlatformContext } from 'Types'; -const FormBodySection = ({ children, has_side_note, side_note }) => { - const { is_appstore } = React.useContext(PlatformContext); +export type TFormBodySection = { + has_side_note?: boolean; + side_note?: string | React.ReactElement; +}; + +const FormBodySection = ({ children, has_side_note, side_note }: React.PropsWithChildren) => { + const { is_appstore }: Partial = React.useContext(PlatformContext); if (has_side_note) { return (
@@ -25,11 +30,7 @@ const FormBodySection = ({ children, has_side_note, side_note }) => {
); } - return children; -}; -FormBodySection.prototype = { - children: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), - has_side_note: PropTypes.bool, - side_note: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), + return children as JSX.Element; }; + export default FormBodySection; diff --git a/packages/account/src/Components/form-body-section/index.js b/packages/account/src/Components/form-body-section/index.js deleted file mode 100644 index 04c4a2a098b9..000000000000 --- a/packages/account/src/Components/form-body-section/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import FormBodySection from './form-body-section.jsx'; - -export default FormBodySection; diff --git a/packages/account/src/Components/form-body-section/index.ts b/packages/account/src/Components/form-body-section/index.ts new file mode 100644 index 000000000000..14d01ddef261 --- /dev/null +++ b/packages/account/src/Components/form-body-section/index.ts @@ -0,0 +1,3 @@ +import FormBodySection from './form-body-section'; + +export default FormBodySection;