From 45fa220dcfdb5c64c49b29870624c58124b8094f Mon Sep 17 00:00:00 2001 From: MANDEEP N H <146331633+mandeepnh5@users.noreply.github.com> Date: Thu, 26 Dec 2024 07:04:40 +0000 Subject: [PATCH 1/2] Update Recurrence options jest to vitest --- ...ence.test.tsx => CustomRecurrence.spec.tsx} | 18 +++++++++--------- ...ons.test.tsx => RecurrenceOptions.spec.tsx} | 18 +++++++++--------- 2 files changed, 18 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..f7254739cf 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,19 @@ 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..40fa5dd048 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,19 @@ 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(), }, })); From d30d12ff3d26a72ff8e25828d2b1eafffe3730b8 Mon Sep 17 00:00:00 2001 From: MANDEEP N H <146331633+mandeepnh5@users.noreply.github.com> Date: Thu, 26 Dec 2024 07:08:41 +0000 Subject: [PATCH 2/2] Fix linting issues --- src/components/RecurrenceOptions/CustomRecurrence.spec.tsx | 5 +++-- src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx b/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx index f7254739cf..236e34e855 100644 --- a/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx +++ b/src/components/RecurrenceOptions/CustomRecurrence.spec.tsx @@ -49,13 +49,14 @@ const translations = JSON.parse( ); vi.mock('@mui/x-date-pickers/DateTimePicker', async () => { - const actual = await vi.importActual('@mui/x-date-pickers/DesktopDateTimePicker'); + const actual = await vi.importActual( + '@mui/x-date-pickers/DesktopDateTimePicker', + ); return { DateTimePicker: actual.DesktopDateTimePicker, }; }); - vi.mock('react-toastify', () => ({ toast: { success: vi.fn(), diff --git a/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx b/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx index 40fa5dd048..07adf7bd16 100644 --- a/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx +++ b/src/components/RecurrenceOptions/RecurrenceOptions.spec.tsx @@ -53,13 +53,14 @@ const translations = { }; vi.mock('@mui/x-date-pickers/DateTimePicker', async () => { - const actual = await vi.importActual('@mui/x-date-pickers/DesktopDateTimePicker'); + const actual = await vi.importActual( + '@mui/x-date-pickers/DesktopDateTimePicker', + ); return { DateTimePicker: actual.DesktopDateTimePicker, }; }); - vi.mock('react-toastify', () => ({ toast: { success: vi.fn(),