diff --git a/packages/cashier/src/components/verification-email/__tests__/verification-email.spec.js b/packages/cashier/src/components/verification-email/__tests__/verification-email.spec.tsx similarity index 59% rename from packages/cashier/src/components/verification-email/__tests__/verification-email.spec.js rename to packages/cashier/src/components/verification-email/__tests__/verification-email.spec.tsx index 94803c460439..68c4fe005bf3 100644 --- a/packages/cashier/src/components/verification-email/__tests__/verification-email.spec.js +++ b/packages/cashier/src/components/verification-email/__tests__/verification-email.spec.tsx @@ -9,13 +9,17 @@ jest.mock('Stores/connect.js', () => ({ })); describe('', () => { - const resendVerificationEmail = jest.fn(); - const setIsResendClicked = jest.fn(); + const mockProps = () => ({ + is_resend_clicked: false, + is_withdrawal: false, + resendVerificationEmail: jest.fn(), + setIsResendClicked: jest.fn(), + }); it('component should be rendered', () => { - const { container } = render(); + const props = mockProps(); + render(); - expect(container.querySelector('.verification-email')).toBeInTheDocument(); expect(screen.getByText("We've sent you an email.")).toBeInTheDocument(); expect( screen.getByText('Please check your email for the verification link to complete the process.') @@ -23,38 +27,47 @@ describe('', () => { }); it("React.Fragment should be rendered if 'is_resend_clicked' prop is true", () => { - const { container } = render(); + const props = mockProps(); + props.is_resend_clicked = true; + + render(); + const btn = screen.getByRole('button'); expect(screen.getByText("Didn't receive the email?")).toBeInTheDocument(); expect( screen.getByText("Check your spam or junk folder. If it's not there, try resending the email.") ).toBeInTheDocument(); - expect(container.querySelector('.verification-email__resend-button')).toBeInTheDocument(); + expect(btn).toHaveClass('verification-email__resend-button'); }); it('resendVerificationEmail func should be triggered when resend button in clicked', () => { - const { container } = render( - - ); + const props = mockProps(); + props.is_resend_clicked = true; + + render(); - const btn = container.querySelector('.verification-email__resend-button'); + const btn = screen.getByRole('button', { name: 'Resend email' }); fireEvent.click(btn); - expect(resendVerificationEmail).toHaveBeenCalledTimes(1); + expect(props.resendVerificationEmail).toHaveBeenCalledTimes(1); }); it("button with 'Didn't receive the email?' text should be rendered when 'is_resend_clicked' prop is false", () => { - render(); + const props = mockProps(); + + render(); expect(screen.getByRole('button', { name: "Didn't receive the email?" })).toBeInTheDocument(); }); it('setIsResendClicked func should be triggered', () => { - render(); + const props = mockProps(); + + render(); const btn = screen.getByRole('button', { name: "Didn't receive the email?" }); fireEvent.click(btn); - expect(setIsResendClicked).toHaveBeenCalledTimes(1); + expect(props.setIsResendClicked).toHaveBeenCalledTimes(1); }); }); diff --git a/packages/cashier/src/components/verification-email/index.js b/packages/cashier/src/components/verification-email/index.js deleted file mode 100644 index 8e2b17cb2c41..000000000000 --- a/packages/cashier/src/components/verification-email/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import VerificationEmail from './verification-email.jsx'; - -export default VerificationEmail; diff --git a/packages/cashier/src/components/verification-email/index.ts b/packages/cashier/src/components/verification-email/index.ts new file mode 100644 index 000000000000..e300bb7505e1 --- /dev/null +++ b/packages/cashier/src/components/verification-email/index.ts @@ -0,0 +1,3 @@ +import VerificationEmail from './verification-email'; + +export default VerificationEmail; diff --git a/packages/cashier/src/components/verification-email/verification-email.jsx b/packages/cashier/src/components/verification-email/verification-email.tsx similarity index 85% rename from packages/cashier/src/components/verification-email/verification-email.jsx rename to packages/cashier/src/components/verification-email/verification-email.tsx index dffaa09a088b..764f1319d5cf 100644 --- a/packages/cashier/src/components/verification-email/verification-email.jsx +++ b/packages/cashier/src/components/verification-email/verification-email.tsx @@ -1,11 +1,22 @@ -import PropTypes from 'prop-types'; import React from 'react'; import { Button, Icon, Text } from '@deriv/components'; import { localize, Localize } from '@deriv/translations'; import ResendEmailButtonWrapper from 'Components/resend-email-button-wrapper'; import './verification-email.scss'; -const VerificationEmail = ({ is_resend_clicked, is_withdrawal, resendVerificationEmail, setIsResendClicked }) => ( +type TVerificationEmailProps = { + is_resend_clicked: boolean; + is_withdrawal: boolean; + resendVerificationEmail: () => void; + setIsResendClicked: (is_resend_clicked: boolean) => void; +}; + +const VerificationEmail = ({ + is_resend_clicked, + is_withdrawal, + resendVerificationEmail, + setIsResendClicked, +}: TVerificationEmailProps) => (
@@ -43,11 +54,4 @@ const VerificationEmail = ({ is_resend_clicked, is_withdrawal, resendVerificatio
); -VerificationEmail.propTypes = { - is_resend_clicked: PropTypes.bool, - is_withdrawal: PropTypes.bool, - resendVerificationEmail: PropTypes.func, - setIsResendClicked: PropTypes.func, -}; - export default VerificationEmail;