From cb5c25502192d9e9827cecce3740c7163e357e38 Mon Sep 17 00:00:00 2001 From: Bandhan Majumder <133476557+bandhan-majumder@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:56:59 +0530 Subject: [PATCH] Refactor: jest to vitest : Fixes #2547 (#2641) * Refactor: jest to vitest : Fixes #2547 * Refactor: jest to vitest : Fixes #2547 * updated src/screens/EventVolunteers/Requests.spec.tsx --------- Co-authored-by: bandhan-majumder Co-authored-by: Bandhan Majumder --- .../{Requests.test.tsx => Requests.spec.tsx} | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) rename src/screens/EventVolunteers/Requests/{Requests.test.tsx => Requests.spec.tsx} (92%) diff --git a/src/screens/EventVolunteers/Requests/Requests.test.tsx b/src/screens/EventVolunteers/Requests/Requests.spec.tsx similarity index 92% rename from src/screens/EventVolunteers/Requests/Requests.test.tsx rename to src/screens/EventVolunteers/Requests/Requests.spec.tsx index 3b55ea872c..e51e28ab3f 100644 --- a/src/screens/EventVolunteers/Requests/Requests.test.tsx +++ b/src/screens/EventVolunteers/Requests/Requests.spec.tsx @@ -1,3 +1,10 @@ +/** + * Testing component for managing and displaying Volunteer Membership requests for an event. + * + * This component allows users to view, filter, sort, and create action items. It also allows users to accept or reject volunteer membership requests. + * + * + */ import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; import { LocalizationProvider } from '@mui/x-date-pickers'; @@ -20,11 +27,12 @@ import { UPDATE_ERROR_MOCKS, } from './Requests.mocks'; import { toast } from 'react-toastify'; +import { vi } from 'vitest'; -jest.mock('react-toastify', () => ({ +vi.mock('react-toastify', () => ({ toast: { - success: jest.fn(), - error: jest.fn(), + success: vi.fn(), + error: vi.fn(), }, })); @@ -74,14 +82,14 @@ const renderRequests = (link: ApolloLink): RenderResult => { describe('Testing Requests Screen', () => { beforeAll(() => { - jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), + vi.mock('react-router-dom', async () => ({ + ...(await vi.importActual('react-router-dom')), useParams: () => ({ orgId: 'orgId', eventId: 'eventId' }), })); }); afterAll(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should redirect to fallback URL if URL params are undefined', async () => { @@ -102,10 +110,7 @@ describe('Testing Requests Screen', () => { , ); - - await waitFor(() => { - expect(screen.getByTestId('paramsError')).toBeInTheDocument(); - }); + expect(window.location.pathname).toBe('/'); }); it('should render Requests screen', async () => {