Skip to content

Commit

Permalink
fix: failing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ameerul-deriv committed May 10, 2024
1 parent c00d04e commit 53898a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const mockProps = {
shouldShowPaymentMethodDisplayName: false,
};

jest.mock('@deriv-com/ui', () => ({
...jest.requireActual('@deriv-com/ui'),
useDevice: jest.fn(() => ({ isMobile: false })),
}));

describe('PaymentMethodCard', () => {
it('should render the component correctly', () => {
render(<PaymentMethodCard {...mockProps} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { PaymentMethodCardBody } from '../PaymentMethodCardBody';

jest.mock('@deriv-com/ui', () => ({
...jest.requireActual('@deriv-com/ui'),
useDevice: jest.fn(() => {
false;
}),
useDevice: jest.fn(() => ({ isMobile: false })),
}));

describe('PaymentMethodCardBody', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { PaymentMethodsListContent } from '../PaymentMethodsListContent';

jest.mock('@/hooks', () => ({
...jest.requireActual('@/hooks'),
api: {
advertiserPaymentMethods: {
useDelete: jest.fn(),
},
},
}));

const mockPaymentMethodsData: THooks.AdvertiserPaymentMethods.Get = [
{
display_name: 'Other',
Expand Down Expand Up @@ -72,6 +63,15 @@ const mockUseDeleteResponse: ReturnType<typeof api.advertiserPaymentMethods.useD
variables: {},
};

jest.mock('@/hooks', () => ({
...jest.requireActual('@/hooks'),
api: {
advertiserPaymentMethods: {
useDelete: jest.fn(() => mockUseDeleteResponse),
},
},
}));

jest.mock('@/components/Modals', () => ({
...jest.requireActual('@/components/Modals'),
PaymentMethodErrorModal: jest.fn(({ isModalOpen, onConfirm }: ComponentProps<typeof PaymentMethodErrorModal>) => {
Expand Down Expand Up @@ -99,6 +99,11 @@ jest.mock('@/components/Modals', () => ({
}),
}));

jest.mock('@deriv-com/ui', () => ({
...jest.requireActual('@deriv-com/ui'),
useDevice: jest.fn().mockReturnValue({ isMobile: false }),
}));

const mockUseDelete = api.advertiserPaymentMethods.useDelete as jest.MockedFunction<
typeof api.advertiserPaymentMethods.useDelete
>;
Expand Down

0 comments on commit 53898a5

Please sign in to comment.