Skip to content

Commit

Permalink
fix test cases because of refactoring the component (#5029)
Browse files Browse the repository at this point in the history
  • Loading branch information
george-usynin-deriv committed Mar 14, 2022
1 parent fe25fb0 commit 1b362ac
Showing 1 changed file with 3 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import PaymentAgentList from '../payment-agent-list';
import { createBrowserHistory } from 'history';
import { Router } from 'react-router';
import { isMobile } from '@deriv/shared';

jest.mock('Stores/connect', () => ({
__esModule: true,
Expand All @@ -14,6 +13,7 @@ jest.mock('Stores/connect', () => ({
jest.mock('Components/Error/error', () => () => <div>PaymentAgentWithdrawError</div>);
jest.mock('Components/Email/email-sent', () => () => <div>The email has been sent!</div>);
jest.mock('Components/Form/payment-agent-withdraw-form', () => () => <div>Payment agent withdraw form</div>);
jest.mock('Components/Form/payment-agent-deposit', () => () => <div>Payment agent deposit</div>);

jest.mock('@deriv/components', () => ({
...jest.requireActual('@deriv/components'),
Expand All @@ -31,35 +31,7 @@ describe('<PaymentAgentList />', () => {
is_loading: false,
is_payment_agent_withdraw: false,
payment_agent_active_tab_index: 0,
payment_agent_list: [
{
email: 'mb+pa1@binary.com',
name: 'Ms QA script mbpaULOta',
phones: '+62417576632',
supported_banks: 'cash',
urls: 'https://www.payagent.com',
},
{
email: 'pr+cr1@deriv.com',
name: 'Ms QA script prcrFDQ',
phones: '+62417597718',
supported_banks: 'paypal,hsbc',
urls: 'https://deriv.com/',
},
{
email: 'pr+cr1@binary.com',
name: 'Ms QA script prcrfWn',
phones: '+62417511398',
supported_banks: 'paypal,hsbc',
urls: 'https://deriv.com/',
},
],
supported_banks: [
{ text: 'cash', value: 'cash' },
{ text: 'paypal', value: 'paypal' },
],
verification_code: '',
onChangePaymentMethod: jest.fn(),
onMount: jest.fn(),
};

Expand All @@ -72,22 +44,7 @@ describe('<PaymentAgentList />', () => {
it('should show proper messages, tabs and titles in Deposit tab', () => {
renderWithRouter(<PaymentAgentList {...props} />);

expect(
screen.getByText(
'A payment agent is authorised to process deposits and withdrawals for you if your local payment methods or currencies are not supported on Deriv.'
)
).toBeInTheDocument();
expect(
screen.getAllByRole('listitem').find(listitem => listitem.textContent === 'Deposit')
).toBeInTheDocument();
expect(
screen.getAllByRole('listitem').find(listitem => listitem.textContent === 'Withdrawal')
).toBeInTheDocument();
expect(screen.getByText('Payment agents')).toBeInTheDocument();
expect(screen.getByText('Choose a payment agent and contact them for instructions.')).toBeInTheDocument();
expect(screen.getByText('Ms QA script mbpaULOta')).toBeInTheDocument();
expect(screen.getByText('Ms QA script prcrFDQ')).toBeInTheDocument();
expect(screen.getByText('Ms QA script prcrfWn')).toBeInTheDocument();
expect(screen.getByText('Payment agent deposit')).toBeInTheDocument();
expect(screen.getByText('DISCLAIMER')).toBeInTheDocument();
expect(
screen.getByText(
Expand All @@ -102,20 +59,6 @@ describe('<PaymentAgentList />', () => {
expect(screen.getByText('Loading')).toBeInTheDocument();
});

it('should trigger onChange callback when the user selects payment agent from the list in Mobile mode', () => {
isMobile.mockReturnValue(true);
renderWithRouter(<PaymentAgentList {...props} />);

const select_native = screen.getByRole('combobox');
fireEvent.change(select_native, {
target: {
value: 'paypal',
},
});

expect(props.onChangePaymentMethod).toHaveBeenCalledTimes(1);
});

it('should show withdrawal error message in Withdrawal tab', () => {
const error = {
code: 'error code',
Expand Down

1 comment on commit 1b362ac

@vercel
Copy link

@vercel vercel bot commented on 1b362ac Mar 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.