diff --git a/packages/wallets/src/features/cfd/modals/MT5PasswordModal/MT5PasswordModal.tsx b/packages/wallets/src/features/cfd/modals/MT5PasswordModal/MT5PasswordModal.tsx index bb08b7eacef5..43bfbaea7bbb 100644 --- a/packages/wallets/src/features/cfd/modals/MT5PasswordModal/MT5PasswordModal.tsx +++ b/packages/wallets/src/features/cfd/modals/MT5PasswordModal/MT5PasswordModal.tsx @@ -18,7 +18,7 @@ import { platformPasswordResetRedirectLink } from '../../../../utils/cfd'; import { validPassword, validPasswordMT5 } from '../../../../utils/password-validation'; import { CFD_PLATFORMS, JURISDICTION, MARKET_TYPE, PlatformDetails, PRODUCT } from '../../constants'; import { CreatePassword, CreatePasswordMT5, EnterPassword, MT5ResetPasswordModal } from '../../screens'; -import { MT5AccountAdded } from '../MT5AccountAdded'; +import MT5AccountAdded from '../MT5AccountAdded/MT5AccountAdded'; import { PasswordLimitExceededModal } from '../PasswordLimitExceededModal'; import { MT5PasswordModalFooter, SuccessModalFooter } from './MT5PasswordModalFooters'; import './MT5PasswordModal.scss'; @@ -63,16 +63,7 @@ const MT5PasswordModal: React.FC = ({ isVirtual, marketType, platform, p const { data: settingsData } = useSettings(); const { localize } = useTranslations(); - const { - address_city: addressCity, - address_line_1: addressLine1, - address_postcode: addressPostcode, - address_state: addressState, - country_code: countryCode, - email, - first_name: firstName, - phone, - } = settingsData; + const { email } = settingsData; const [password, setPassword] = useState(''); @@ -107,10 +98,10 @@ const MT5PasswordModal: React.FC = ({ isVirtual, marketType, platform, p createMT5AccountMutate({ payload: { account_type: categoryAccountType, - address: addressLine1 ?? '', - city: addressCity ?? '', - country: countryCode ?? '', - email: email ?? '', + address: settingsData?.address_line_1 ?? '', + city: settingsData?.address_city ?? '', + country: settingsData?.country_code ?? '', + email: settingsData?.email ?? '', leverage: availableMT5AccountsData?.find(acc => acc.market_type === marketType)?.leverage ?? 500, mainPassword: password, ...(selectedJurisdiction && !isDemo ? { company: selectedJurisdiction } : {}), @@ -128,10 +119,10 @@ const MT5PasswordModal: React.FC = ({ isVirtual, marketType, platform, p mt5_account_type: 'financial_stp', })), ...(marketType === MARKET_TYPE.ALL && { product }), - name: firstName ?? '', - phone: phone ?? '', - state: addressState ?? '', - zipCode: addressPostcode ?? '', + name: settingsData?.first_name ?? '', + phone: settingsData?.phone ?? '', + state: settingsData?.address_state ?? '', + zipCode: settingsData?.address_postcode ?? '', }, }); }, [ @@ -142,14 +133,14 @@ const MT5PasswordModal: React.FC = ({ isVirtual, marketType, platform, p marketType, mt5Platform, password, - addressCity, - addressLine1, - addressPostcode, - addressState, - countryCode, - email, - firstName, - phone, + settingsData?.address_city, + settingsData?.address_line_1, + settingsData?.address_postcode, + settingsData?.address_state, + settingsData?.country_code, + settingsData?.email, + settingsData?.first_name, + settingsData?.phone, tradingPasswordChangeMutateAsync, selectedJurisdiction, product, diff --git a/packages/wallets/src/features/cfd/modals/MT5PasswordModal/__tests__/MT5PasswordModal.spec.tsx b/packages/wallets/src/features/cfd/modals/MT5PasswordModal/__tests__/MT5PasswordModal.spec.tsx deleted file mode 100644 index 6201627c2f63..000000000000 --- a/packages/wallets/src/features/cfd/modals/MT5PasswordModal/__tests__/MT5PasswordModal.spec.tsx +++ /dev/null @@ -1,555 +0,0 @@ -import React from 'react'; -import { - useAccountStatus, - useActiveWalletAccount, - useAvailableMT5Accounts, - useCreateMT5Account, - useMT5AccountsList, - useSettings, - useTradingPlatformPasswordChange, - useVerifyEmail, -} from '@deriv/api-v2'; -import { useDevice } from '@deriv-com/ui'; -import { render, screen } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import { useModal } from '../../../../../components/ModalProvider'; -import MT5PasswordModal from '../MT5PasswordModal'; - -jest.mock('@deriv/api-v2'); -jest.mock('../../../../../components/ModalProvider'); -jest.mock('@deriv-com/ui', () => ({ - ...jest.requireActual('@deriv-com/ui'), - Loader: jest.fn(() =>
Loading...
), - useDevice: jest.fn(() => ({ isDesktop: true })), -})); - -jest.mock('../../../../../components/Base', () => ({ - ModalStepWrapper: ({ - children, - renderFooter, - title, - }: { - children: React.ReactNode; - renderFooter?: () => React.ReactNode; - title?: string; - }) => ( -
- {title &&
{title}
} - {children} - {renderFooter &&
{renderFooter()}
} -
- ), - ModalWrapper: ({ children }: { children: React.ReactNode }) =>
{children}
, -})); - -jest.mock('../../../../../components', () => ({ - SentEmailContent: () =>
SentEmailContent
, - WalletError: () =>
WalletError
, -})); - -jest.mock('../../../screens', () => ({ - CreatePassword: ({ - onPasswordChange, - onPrimaryClick, - }: { - onPasswordChange: () => void; - onPrimaryClick: () => void; - }) => ( -
- CreatePassword - - -
- ), - CreatePasswordMT5: ({ - onPasswordChange, - onPrimaryClick, - onTncChange, - }: { - onPasswordChange: () => void; - onPrimaryClick: () => void; - onTncChange: () => void; - }) => ( -
- CreatePasswordMT5 - - - -
- ), - EnterPassword: ({ - onPasswordChange, - onPrimaryClick, - onSecondaryClick, - onTncChange, - }: { - onPasswordChange: () => void; - onPrimaryClick: () => void; - onSecondaryClick: () => void; - onTncChange: () => void; - }) => ( -
- EnterPassword - - - - -
- ), - MT5ResetPasswordModal: ({ - onClickSubmitPasswordChange, - sendEmailVerification, - }: { - onClickSubmitPasswordChange: ({ - currentPassword, - newPassword, - }: { - currentPassword: string; - newPassword: string; - }) => void; - sendEmailVerification: () => void; - }) => ( -
- MT5ResetPasswordModal - - -
- ), -})); - -jest.mock('../../MT5AccountAdded', () => ({ - MT5AccountAdded: () =>
MT5AccountAdded
, -})); - -jest.mock('../../PasswordLimitExceededModal', () => ({ - PasswordLimitExceededModal: ({ - onPrimaryClick, - onSecondaryClick, - }: { - onPrimaryClick: () => void; - onSecondaryClick: () => void; - }) => ( -
- PasswordLimitExceededModal - - -
- ), -})); - -jest.mock('../MT5PasswordModalFooters', () => ({ - MT5PasswordModalFooter: ({ - onPrimaryClick, - onSecondaryClick, - }: { - onPrimaryClick: () => void; - onSecondaryClick: () => void; - }) => ( -
- MT5PasswordModalFooter - - -
- ), - SuccessModalFooter: () =>
SuccessModalFooter
, -})); - -describe('MT5PasswordModal', () => { - const mockTradingPasswordChangeMutateAsync = jest.fn(); - const mockEmailVerificationMutate = jest.fn(); - const mockCreateMT5AccountMutate = jest.fn(); - - const defaultProps = { - marketType: 'synthetic' as const, - platform: 'ctrader' as const, - }; - - beforeEach(() => { - (useCreateMT5Account as jest.Mock).mockReturnValue({ error: undefined, mutate: jest.fn(), status: 'idle' }); - (useTradingPlatformPasswordChange as jest.Mock).mockReturnValue({ mutateAsync: jest.fn() }); - (useAccountStatus as jest.Mock).mockReturnValue({ data: undefined, isLoading: false }); - (useModal as jest.Mock).mockReturnValue({ getModalState: jest.fn(), hide: jest.fn() }); - (useVerifyEmail as jest.Mock).mockReturnValue({ error: undefined, status: 'idle' }); - (useSettings as jest.Mock).mockReturnValue({ data: { email: undefined } }); - (useActiveWalletAccount as jest.Mock).mockReturnValue({ data: undefined }); - (useAvailableMT5Accounts as jest.Mock).mockReturnValue({ - data: [{ market_type: 'synthetic', product: 'standard', shortcode: 'bvi' }], - }); - (useMT5AccountsList as jest.Mock).mockReturnValue({ - data: [{ login: '12345', market_type: 'financial' }], - }); - }); - - it('renders loader if isLoading is true', () => { - (useAccountStatus as jest.Mock).mockReturnValue({ isLoading: true }); - - render(); - - expect(screen.getByText('Loading...')).toBeInTheDocument(); - }); - - it('renders EnterPassword by default for desktop view', () => { - render(); - - expect(screen.getByText('EnterPassword')).toBeInTheDocument(); - }); - - it('renders EnterPassword by default with title and footer for mobile view', () => { - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - - render(); - - expect(screen.getByText('EnterPassword')).toBeInTheDocument(); - expect(screen.getByText('MT5PasswordModalFooter')).toBeInTheDocument(); - expect(screen.getByText('Add a real Deriv MT5 account')).toBeInTheDocument(); - }); - - it('renders default content for demo account', () => { - (useActiveWalletAccount as jest.Mock).mockReturnValue({ data: { is_virtual: true } }); - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - - render(); - - expect(screen.getByText('EnterPassword')).toBeInTheDocument(); - expect(screen.getByText('MT5PasswordModalFooter')).toBeInTheDocument(); - expect(screen.getByText('Add a demo Deriv MT5 account')).toBeInTheDocument(); - }); - - it('renders WalletError for account creation errors', () => { - (useCreateMT5Account as jest.Mock).mockReturnValue({ - error: { error: { code: 'Error', message: 'Error message' } }, - status: 'error', - }); - - render(); - - expect(screen.getByText('WalletError')).toBeInTheDocument(); - }); - - it('renders WalletError when email verification fails', () => { - (useVerifyEmail as jest.Mock).mockReturnValue({ - error: { error: { message: 'Error' } }, - status: 'error', - }); - - render(); - - expect(screen.getByText('WalletError')).toBeInTheDocument(); - }); - - it('renders SentEmailContent when email verification succeeds', () => { - (useVerifyEmail as jest.Mock).mockReturnValue({ status: 'success' }); - - render(); - - expect(screen.getByText('SentEmailContent')).toBeInTheDocument(); - }); - - it('handles primary and secondary button clicks in EnterPassword', () => { - (useCreateMT5Account as jest.Mock).mockReturnValue({ mutate: mockCreateMT5AccountMutate, status: 'idle' }); - (useVerifyEmail as jest.Mock).mockReturnValue({ - mutate: mockEmailVerificationMutate, - status: 'idle', - }); - (useSettings as jest.Mock).mockReturnValue({ - data: { - address_city: 'city', - address_line_1: 'address', - address_postcode: 'postcode', - address_state: 'state', - country_code: 'country', - email: 'test@example.com', - first_name: 'first_name', - phone: 'phone', - }, - }); - - render(); - - const passwordInput = screen.getByTestId('dt_enter_password_input'); - const tncCheckbox = screen.getByTestId('dt_enter_password_tnc'); - userEvent.type(passwordInput, 'test123'); - userEvent.click(tncCheckbox); - userEvent.click(screen.getByTestId('dt_enter_password_primary_button')); - expect(mockCreateMT5AccountMutate).toHaveBeenCalledWith({ - payload: { - account_type: 'gaming', - address: 'address', - city: 'city', - country: 'country', - email: 'test@example.com', - leverage: 500, - mainPassword: 'test123', - name: 'first_name', - phone: 'phone', - state: 'state', - zipCode: 'postcode', - }, - }); - - userEvent.click(screen.getByTestId('dt_enter_password_secondary_button')); - expect(mockEmailVerificationMutate).toHaveBeenCalledWith({ - type: 'trading_platform_mt5_password_reset', - url_parameters: { - redirect_to: 10, - }, - verify_email: 'test@example.com', - }); - }); - - it('renders CreatePassword when MT5 password is not set', () => { - (useAccountStatus as jest.Mock).mockReturnValue({ data: { is_mt5_password_not_set: true }, isLoading: false }); - - render(); - - expect(screen.getByText('CreatePassword')).toBeInTheDocument(); - }); - - it('renders CreatePassword with correct button text when MT5 password is not set for mobile view', () => { - (useAccountStatus as jest.Mock).mockReturnValue({ data: { is_mt5_password_not_set: true }, isLoading: false }); - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - - render(); - - expect(screen.getByText('Create Deriv MT5 password')).toBeInTheDocument(); - }); - - it('handles primary button click for CreatePassword', () => { - (useAccountStatus as jest.Mock).mockReturnValue({ data: { is_mt5_password_not_set: true }, isLoading: false }); - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - (useTradingPlatformPasswordChange as jest.Mock).mockReturnValue({ - mutateAsync: mockTradingPasswordChangeMutateAsync, - }); - - render(); - - const input = screen.getByTestId('dt_create_password_input'); - userEvent.type(input, 'test123'); - userEvent.click(screen.getByTestId('dt_create_password_primary_button')); - expect(mockTradingPasswordChangeMutateAsync).toHaveBeenCalledWith({ - new_password: 'test123', - platform: 'mt5', - }); - }); - - it('renders CreatePasswordMT5 when MT5 password is not set and platform is MT5', () => { - (useAccountStatus as jest.Mock).mockReturnValue({ data: { is_mt5_password_not_set: true }, isLoading: false }); - - render(); - - expect(screen.getByText('CreatePasswordMT5')).toBeInTheDocument(); - }); - - it('handles primary button click for CreatePasswordMT5', () => { - (useAccountStatus as jest.Mock).mockReturnValue({ data: { is_mt5_password_not_set: true }, isLoading: false }); - (useTradingPlatformPasswordChange as jest.Mock).mockReturnValue({ - mutateAsync: mockTradingPasswordChangeMutateAsync, - }); - - render(); - - const passwordInput = screen.getByTestId('dt_create_password_mt5_input'); - const tncCheckbox = screen.getByTestId('dt_create_password_mt5_tnc'); - userEvent.type(passwordInput, 'test123'); - userEvent.click(tncCheckbox); - userEvent.click(screen.getByTestId('dt_create_password_mt5_primary_button')); - expect(mockTradingPasswordChangeMutateAsync).toHaveBeenCalledWith({ - new_password: 'test123', - platform: 'mt5', - }); - }); - - it('renders MT5ResetPasswordModal when password update is required', () => { - (useCreateMT5Account as jest.Mock).mockReturnValue({ - error: { error: { code: 'InvalidTradingPlatformPasswordFormat' } }, - status: 'error', - }); - - render(); - - expect(screen.getByText('MT5ResetPasswordModal')).toBeInTheDocument(); - }); - - it('renders MT5ResetPasswordModal with correct title when password update is required for mobile view', () => { - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - (useCreateMT5Account as jest.Mock).mockReturnValue({ - error: { error: { code: 'InvalidTradingPlatformPasswordFormat' } }, - status: 'error', - }); - - render(); - - expect(screen.getByText('MT5ResetPasswordModal')).toBeInTheDocument(); - expect(screen.getByText('Deriv MT5 latest password requirements')).toBeInTheDocument(); - }); - - it('handles primary and secondary button clicks for MT5ResetPasswordModal', () => { - (useSettings as jest.Mock).mockReturnValue({ data: { email: 'test@example.com' } }); - (useCreateMT5Account as jest.Mock).mockReturnValue({ - error: { error: { code: 'InvalidTradingPlatformPasswordFormat' } }, - status: 'error', - }); - (useTradingPlatformPasswordChange as jest.Mock).mockReturnValue({ - mutateAsync: mockTradingPasswordChangeMutateAsync, - }); - (useVerifyEmail as jest.Mock).mockReturnValue({ - mutate: mockEmailVerificationMutate, - status: 'idle', - }); - - render(); - - userEvent.click(screen.getByTestId('dt_mt5_reset_password_modal_primary_button')); - expect(mockTradingPasswordChangeMutateAsync).toHaveBeenCalledWith({ - new_password: 'newPass', - old_password: 'oldPass', - platform: 'mt5', - }); - - userEvent.click(screen.getByTestId('dt_mt5_reset_password_modal_secondary_button')); - expect(mockEmailVerificationMutate).toHaveBeenCalledWith({ - type: 'trading_platform_mt5_password_reset', - url_parameters: { - redirect_to: 10, - }, - verify_email: 'test@example.com', - }); - }); - - it('renders MT5AccountAdded when account creation succeeds', () => { - (useAccountStatus as jest.Mock).mockReturnValue({ data: { is_mt5_password_not_set: false }, isLoading: false }); - (useCreateMT5Account as jest.Mock).mockReturnValue({ - isSuccess: true, - status: 'success', - }); - - render(); - - expect(screen.getByText('MT5AccountAdded')).toBeInTheDocument(); - }); - - it('renders PasswordLimitExceededModal when password reset is required', () => { - (useCreateMT5Account as jest.Mock).mockReturnValue({ - error: { error: { code: 'PasswordReset' } }, - status: 'error', - }); - - render(); - - expect(screen.getByText('PasswordLimitExceededModal')).toBeInTheDocument(); - }); - - it('handles primary button click for PasswordLimitExceededModal', () => { - (useSettings as jest.Mock).mockReturnValue({ data: { email: 'test@example.com' } }); - (useCreateMT5Account as jest.Mock).mockReturnValue({ - error: { error: { code: 'PasswordReset' } }, - status: 'error', - }); - (useVerifyEmail as jest.Mock).mockReturnValue({ - mutate: mockEmailVerificationMutate, - status: 'idle', - }); - - render(); - - userEvent.click(screen.getByTestId('dt_password_limit_exceeded_modal_secondary_button')); - expect(mockEmailVerificationMutate).toHaveBeenCalledWith({ - type: 'trading_platform_mt5_password_reset', - url_parameters: { - redirect_to: 10, - }, - verify_email: 'test@example.com', - }); - }); - - it('handles secondary button click for MT5PasswordModalFooter', () => { - (useActiveWalletAccount as jest.Mock).mockReturnValue({ data: { is_virtual: false } }); - (useSettings as jest.Mock).mockReturnValue({ data: { email: 'test@example.com' } }); - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - (useVerifyEmail as jest.Mock).mockReturnValue({ - mutate: mockEmailVerificationMutate, - status: 'idle', - }); - - render(); - - userEvent.click(screen.getByTestId('dt_mt5_password_modal_footer_secondary_button')); - expect(mockEmailVerificationMutate).toHaveBeenCalledWith({ - type: 'trading_platform_mt5_password_reset', - url_parameters: { - redirect_to: 10, - }, - verify_email: 'test@example.com', - }); - }); - - it('renders SuccessModalFooter when account creation is successful', () => { - (useAccountStatus as jest.Mock).mockReturnValue({ data: { is_mt5_password_not_set: true }, isLoading: false }); - (useCreateMT5Account as jest.Mock).mockReturnValue({ isSuccess: true, status: 'success' }); - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - - render(); - - expect(screen.getByText('SuccessModalFooter')).toBeInTheDocument(); - }); - - it('sends create MT5 account request with correct parameters for demo account', () => { - (useCreateMT5Account as jest.Mock).mockReturnValue({ mutate: mockCreateMT5AccountMutate, status: 'idle' }); - (useActiveWalletAccount as jest.Mock).mockReturnValue({ data: { is_virtual: true } }); - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - (useSettings as jest.Mock).mockReturnValue({ - data: { - address_city: 'city', - address_line_1: 'address', - address_postcode: 'postcode', - address_state: 'state', - country_code: 'country', - email: 'test@example.com', - first_name: 'first_name', - phone: 'phone', - }, - }); - - render(); - - userEvent.click(screen.getByTestId('dt_enter_password_primary_button')); - expect(mockCreateMT5AccountMutate).toHaveBeenCalledWith({ - payload: { - account_type: 'demo', - address: 'address', - city: 'city', - country: 'country', - email: 'test@example.com', - leverage: 500, - mainPassword: '', - name: 'first_name', - phone: 'phone', - state: 'state', - zipCode: 'postcode', - }, - }); - }); -}); diff --git a/packages/wallets/src/features/cfd/modals/MT5PasswordModal/__tests__/MT5PasswordModalFooters.spec.tsx b/packages/wallets/src/features/cfd/modals/MT5PasswordModal/__tests__/MT5PasswordModalFooters.spec.tsx deleted file mode 100644 index 29b9e6c8bd01..000000000000 --- a/packages/wallets/src/features/cfd/modals/MT5PasswordModal/__tests__/MT5PasswordModalFooters.spec.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import React from 'react'; -import { useHistory } from 'react-router-dom'; -import { useDevice } from '@deriv-com/ui'; -import { render, screen } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import { useModal } from '../../../../../components/ModalProvider'; -import { MT5PasswordModalFooter, SuccessModalFooter } from '../MT5PasswordModalFooters'; - -jest.mock('react-router-dom', () => ({ - useHistory: jest.fn(), -})); - -jest.mock('../../../../../components/ModalProvider', () => ({ - useModal: jest.fn(), -})); - -jest.mock('@deriv-com/ui', () => ({ - Button: ({ children, onClick }: { children: React.ReactNode; onClick: () => void }) => ( - - ), - useDevice: jest.fn(), -})); - -describe('SuccessModalFooter', () => { - it('renders default button for demo account', () => { - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - (useModal as jest.Mock).mockReturnValue({ hide: jest.fn() }); - - render(); - expect(screen.getByText('OK')).toBeInTheDocument(); - }); - - it('renders default buttons for real account', () => { - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - (useModal as jest.Mock).mockReturnValue({ hide: jest.fn() }); - const mockHistory = { push: jest.fn() }; - (useHistory as jest.Mock).mockReturnValue(mockHistory); - - render(); - expect(screen.getByText('Maybe later')).toBeInTheDocument(); - expect(screen.getByText('Transfer funds')).toBeInTheDocument(); - }); - - it('calls hide when OK button is clicked for demo account', () => { - const mockHide = jest.fn(); - (useDevice as jest.Mock).mockReturnValue({ isDesktop: true }); - (useModal as jest.Mock).mockReturnValue({ hide: mockHide }); - - render(); - userEvent.click(screen.getByText('OK')); - expect(mockHide).toHaveBeenCalled(); - }); - - it('navigates to transfer page when transfer funds button is clicked', () => { - const mockHide = jest.fn(); - const mockHistory = { push: jest.fn() }; - (useDevice as jest.Mock).mockReturnValue({ isDesktop: true }); - (useModal as jest.Mock).mockReturnValue({ hide: mockHide }); - (useHistory as jest.Mock).mockReturnValue(mockHistory); - - render(); - userEvent.click(screen.getByText('Transfer funds')); - expect(mockHide).toHaveBeenCalled(); - expect(mockHistory.push).toHaveBeenCalledWith('/wallet/account-transfer'); - }); -}); - -describe('MT5PasswordModalFooter', () => { - it('renders default buttons', () => { - (useDevice as jest.Mock).mockReturnValue({ isDesktop: false }); - - render( - - ); - expect(screen.getByText('Forgot password?')).toBeInTheDocument(); - expect(screen.getByText('Add account')).toBeInTheDocument(); - }); - - it('calls onSecondaryClick when forgot password button is clicked', () => { - (useDevice as jest.Mock).mockReturnValue({ isDesktop: true }); - const mockSecondaryClick = jest.fn(); - - render( - - ); - userEvent.click(screen.getByText('Forgot password?')); - expect(mockSecondaryClick).toHaveBeenCalled(); - }); - - it('calls onPrimaryClick when add account button is clicked', () => { - (useDevice as jest.Mock).mockReturnValue({ isDesktop: true }); - const mockPrimaryClick = jest.fn(); - - render( - - ); - userEvent.click(screen.getByText('Add account')); - expect(mockPrimaryClick).toHaveBeenCalled(); - }); -});