From 980444ca1ecdfcceb01e1dc0973a12586f55ad79 Mon Sep 17 00:00:00 2001 From: im-vedant <194vedantgutpa@gmail.com> Date: Wed, 11 Dec 2024 11:41:12 +0530 Subject: [PATCH] chore: migrate src/screens/UserPortal/Donate/Donate.test.tsx from Jest to Vitest --- .../{Donate.test.tsx => Donate.spec.tsx} | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) rename src/screens/UserPortal/Donate/{Donate.test.tsx => Donate.spec.tsx} (93%) diff --git a/src/screens/UserPortal/Donate/Donate.test.tsx b/src/screens/UserPortal/Donate/Donate.spec.tsx similarity index 93% rename from src/screens/UserPortal/Donate/Donate.test.tsx rename to src/screens/UserPortal/Donate/Donate.spec.tsx index c4d435415e..b13056f5f9 100644 --- a/src/screens/UserPortal/Donate/Donate.test.tsx +++ b/src/screens/UserPortal/Donate/Donate.spec.tsx @@ -1,8 +1,14 @@ +/** + * Unit tests for the Donate component. + * + * This file contains tests for the Donate component to ensure it behaves as expected + * under various scenarios. + */ import React, { act } from 'react'; import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; - +import { vi } from 'vitest'; import { ORGANIZATION_DONATION_CONNECTION_LIST, USER_ORGANIZATION_CONNECTION, @@ -132,35 +138,35 @@ async function wait(ms = 100): Promise { }); } -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), - useParams: () => ({ orgId: '' }), +vi.mock('react-router-dom', async () => ({ + ...(await vi.importActual('react-router-dom')), + useParams: vi.fn(() => ({ orgId: '' })), })); -jest.mock('react-toastify', () => ({ +vi.mock('react-toastify', () => ({ toast: { - error: jest.fn(), - success: jest.fn(), + error: vi.fn(), + success: vi.fn(), }, })); describe('Testing Donate Screen [User Portal]', () => { Object.defineProperty(window, 'matchMedia', { writable: true, - value: jest.fn().mockImplementation((query) => ({ + value: vi.fn().mockImplementation((query) => ({ matches: false, media: query, onchange: null, - addListener: jest.fn(), // Deprecated - removeListener: jest.fn(), // Deprecated - addEventListener: jest.fn(), - removeEventListener: jest.fn(), - dispatchEvent: jest.fn(), + addListener: vi.fn(), // Deprecated + removeListener: vi.fn(), // Deprecated + addEventListener: vi.fn(), + removeEventListener: vi.fn(), + dispatchEvent: vi.fn(), })), }); beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); test('Screen should be rendered properly', async () => {