From d99fc8b23ecb0598d2ebfc340bcbb2236f0f56fb Mon Sep 17 00:00:00 2001 From: MANDEEP N H <146331633+mandeepnh5@users.noreply.github.com> Date: Thu, 26 Dec 2024 17:39:45 +0530 Subject: [PATCH] Migrated src/components/RecurrenceOptions/* from Jest to Vitest. (#2911) * Update Recurrence options jest to vitest * Fix linting issues --- ...nce.test.tsx => CustomRecurrence.spec.tsx} | 19 ++++++++++--------- ...ns.test.tsx => RecurrenceOptions.spec.tsx} | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) rename src/components/RecurrenceOptions/{CustomRecurrence.test.tsx => CustomRecurrence.spec.tsx} (98%) rename src/components/RecurrenceOptions/{RecurrenceOptions.test.tsx => RecurrenceOptions.spec.tsx} (97%) diff --git a/src/components/RecurrenceOptions/CustomRecurrence.test.tsx b/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx similarity index 98% rename from src/components/RecurrenceOptions/CustomRecurrence.test.tsx rename to src/components/RecurrenceOptions/CustomRecurrence.spec.tsx index fc0cacf5c4..236e34e855 100644 --- a/src/components/RecurrenceOptions/CustomRecurrence.test.tsx +++ b/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx @@ -9,7 +9,6 @@ import { } from '@testing-library/react'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; -import 'jest-location-mock'; import { I18nextProvider } from 'react-i18next'; import OrganizationEvents from '../../screens/OrganizationEvents/OrganizationEvents'; @@ -23,6 +22,7 @@ import { ThemeProvider } from 'react-bootstrap'; import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import { MOCKS } from '../../screens/OrganizationEvents/OrganizationEventsMocks'; +import { describe, test, expect, vi } from 'vitest'; const theme = createTheme({ palette: { @@ -48,19 +48,20 @@ const translations = JSON.parse( ), ); -jest.mock('@mui/x-date-pickers/DateTimePicker', () => { +vi.mock('@mui/x-date-pickers/DateTimePicker', async () => { + const actual = await vi.importActual( + '@mui/x-date-pickers/DesktopDateTimePicker', + ); return { - DateTimePicker: jest.requireActual( - '@mui/x-date-pickers/DesktopDateTimePicker', - ).DesktopDateTimePicker, + DateTimePicker: actual.DesktopDateTimePicker, }; }); -jest.mock('react-toastify', () => ({ +vi.mock('react-toastify', () => ({ toast: { - success: jest.fn(), - warning: jest.fn(), - error: jest.fn(), + success: vi.fn(), + warning: vi.fn(), + error: vi.fn(), }, })); diff --git a/src/components/RecurrenceOptions/RecurrenceOptions.test.tsx b/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx similarity index 97% rename from src/components/RecurrenceOptions/RecurrenceOptions.test.tsx rename to src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx index 2d283460da..07adf7bd16 100644 --- a/src/components/RecurrenceOptions/RecurrenceOptions.test.tsx +++ b/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx @@ -9,7 +9,6 @@ import { } from '@testing-library/react'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; -import 'jest-location-mock'; import { I18nextProvider } from 'react-i18next'; import OrganizationEvents from '../../screens/OrganizationEvents/OrganizationEvents'; @@ -23,6 +22,7 @@ import { ThemeProvider } from 'react-bootstrap'; import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import { MOCKS } from '../../screens/OrganizationEvents/OrganizationEventsMocks'; +import { describe, test, expect, vi } from 'vitest'; const theme = createTheme({ palette: { @@ -52,19 +52,20 @@ const translations = { ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {})), }; -jest.mock('@mui/x-date-pickers/DateTimePicker', () => { +vi.mock('@mui/x-date-pickers/DateTimePicker', async () => { + const actual = await vi.importActual( + '@mui/x-date-pickers/DesktopDateTimePicker', + ); return { - DateTimePicker: jest.requireActual( - '@mui/x-date-pickers/DesktopDateTimePicker', - ).DesktopDateTimePicker, + DateTimePicker: actual.DesktopDateTimePicker, }; }); -jest.mock('react-toastify', () => ({ +vi.mock('react-toastify', () => ({ toast: { - success: jest.fn(), - warning: jest.fn(), - error: jest.fn(), + success: vi.fn(), + warning: vi.fn(), + error: vi.fn(), }, }));