From b7329089c32b624eeb47beb0494d84320e2b7cdd Mon Sep 17 00:00:00 2001 From: MANDEEP N H <146331633+mandeepnh5@users.noreply.github.com> Date: Tue, 24 Dec 2024 19:30:43 +0000 Subject: [PATCH 1/3] Update Agenda items vitest --- ...t.tsx => AgendaItemsPreviewModal.spec.tsx} | 7 ++++--- ...st.tsx => AgendaItemsUpdateModal.spec.tsx} | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) rename src/components/AgendaItems/{AgendaItemsPreviewModal.test.tsx => AgendaItemsPreviewModal.spec.tsx} (94%) rename src/components/AgendaItems/{AgendaItemsUpdateModal.test.tsx => AgendaItemsUpdateModal.spec.tsx} (96%) diff --git a/src/components/AgendaItems/AgendaItemsPreviewModal.test.tsx b/src/components/AgendaItems/AgendaItemsPreviewModal.spec.tsx similarity index 94% rename from src/components/AgendaItems/AgendaItemsPreviewModal.test.tsx rename to src/components/AgendaItems/AgendaItemsPreviewModal.spec.tsx index 0a7b4646ba..35c67576cc 100644 --- a/src/components/AgendaItems/AgendaItemsPreviewModal.test.tsx +++ b/src/components/AgendaItems/AgendaItemsPreviewModal.spec.tsx @@ -11,6 +11,7 @@ import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import AgendaItemsPreviewModal from './AgendaItemsPreviewModal'; +import { describe, test, expect, vi } from 'vitest'; const mockFormState = { title: 'Test Title', @@ -44,10 +45,10 @@ describe('AgendaItemsPreviewModal', () => { diff --git a/src/components/AgendaItems/AgendaItemsUpdateModal.test.tsx b/src/components/AgendaItems/AgendaItemsUpdateModal.spec.tsx similarity index 96% rename from src/components/AgendaItems/AgendaItemsUpdateModal.test.tsx rename to src/components/AgendaItems/AgendaItemsUpdateModal.spec.tsx index 0f11ea31b2..8d277419fa 100644 --- a/src/components/AgendaItems/AgendaItemsUpdateModal.test.tsx +++ b/src/components/AgendaItems/AgendaItemsUpdateModal.spec.tsx @@ -12,13 +12,14 @@ import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; import { store } from 'state/store'; import i18nForTest from 'utils/i18nForTest'; - import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import AgendaItemsUpdateModal from './AgendaItemsUpdateModal'; import { toast } from 'react-toastify'; import convertToBase64 from 'utils/convertToBase64'; +import type { MockedFunction } from 'vitest'; +import { describe, test, expect, vi } from 'vitest'; const mockFormState = { title: 'Test Title', @@ -67,19 +68,19 @@ const mockAgendaItemCategories = [ }, ]; -const mockHideUpdateModal = jest.fn(); -const mockSetFormState = jest.fn(); -const mockUpdateAgendaItemHandler = jest.fn(); +const mockHideUpdateModal = vi.fn(); +const mockSetFormState = vi.fn(); +const mockUpdateAgendaItemHandler = vi.fn(); const mockT = (key: string): string => key; -jest.mock('react-toastify', () => ({ +vi.mock('react-toastify', () => ({ toast: { - success: jest.fn(), - error: jest.fn(), + success: vi.fn(), + error: vi.fn(), }, })); -jest.mock('utils/convertToBase64'); -const mockedConvertToBase64 = convertToBase64 as jest.MockedFunction< +vi.mock('utils/convertToBase64'); +const mockedConvertToBase64 = convertToBase64 as MockedFunction< typeof convertToBase64 >; From 7bc28fc85d3cd3905ced5fcc1f497ed0181bd43d Mon Sep 17 00:00:00 2001 From: MANDEEP N H <146331633+mandeepnh5@users.noreply.github.com> Date: Wed, 25 Dec 2024 06:00:15 +0000 Subject: [PATCH 2/3] Update jest to vitest --- ...tainer.test.tsx => AgendaItemsContainer.spec.tsx} | 12 +++++------- .../AgendaItems/AgendaItemsContainerProps.ts | 5 +++-- 2 files changed, 8 insertions(+), 9 deletions(-) rename src/components/AgendaItems/{AgendaItemsContainer.test.tsx => AgendaItemsContainer.spec.tsx} (98%) diff --git a/src/components/AgendaItems/AgendaItemsContainer.test.tsx b/src/components/AgendaItems/AgendaItemsContainer.spec.tsx similarity index 98% rename from src/components/AgendaItems/AgendaItemsContainer.test.tsx rename to src/components/AgendaItems/AgendaItemsContainer.spec.tsx index 8b391a2073..f8f6ab948d 100644 --- a/src/components/AgendaItems/AgendaItemsContainer.test.tsx +++ b/src/components/AgendaItems/AgendaItemsContainer.spec.tsx @@ -7,9 +7,7 @@ import { fireEvent, } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import 'jest-localstorage-mock'; import { MockedProvider } from '@apollo/client/testing'; -import 'jest-location-mock'; import { I18nextProvider } from 'react-i18next'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; @@ -24,20 +22,20 @@ import { StaticMockLink } from 'utils/StaticMockLink'; import { props, props2 } from './AgendaItemsContainerProps'; import { MOCKS, MOCKS_ERROR } from './AgendaItemsContainerMocks'; import AgendaItemsContainer from './AgendaItemsContainer'; - +import { describe, test, expect, vi } from 'vitest'; const link = new StaticMockLink(MOCKS, true); const link2 = new StaticMockLink(MOCKS_ERROR, true); -jest.mock('react-toastify', () => ({ +vi.mock('react-toastify', () => ({ toast: { - success: jest.fn(), - error: jest.fn(), + success: vi.fn(), + error: vi.fn(), }, })); //temporarily fixes react-beautiful-dnd droppable method's depreciation error //needs to be fixed in React 19 -jest.spyOn(console, 'error').mockImplementation((message) => { +vi.spyOn(console, 'error').mockImplementation((message) => { if (message.includes('Support for defaultProps will be removed')) { return; } diff --git a/src/components/AgendaItems/AgendaItemsContainerProps.ts b/src/components/AgendaItems/AgendaItemsContainerProps.ts index d6dcf3feca..f19d5ff9df 100644 --- a/src/components/AgendaItems/AgendaItemsContainerProps.ts +++ b/src/components/AgendaItems/AgendaItemsContainerProps.ts @@ -1,4 +1,5 @@ type AgendaItemConnectionType = 'Event'; +import { vi } from 'vitest'; export const props = { agendaItemConnection: 'Event' as AgendaItemConnectionType, @@ -68,7 +69,7 @@ export const props = { }, }, ], - agendaItemRefetch: jest.fn(), + agendaItemRefetch: vi.fn(), agendaItemCategories: [ { _id: 'agendaCategory1', @@ -96,6 +97,6 @@ export const props = { export const props2 = { agendaItemConnection: 'Event' as AgendaItemConnectionType, agendaItemData: [], - agendaItemRefetch: jest.fn(), + agendaItemRefetch: vi.fn(), agendaItemCategories: [], }; From 5a13410af15699bae5f410d159ab0a30882674ab Mon Sep 17 00:00:00 2001 From: MANDEEP N H <146331633+mandeepnh5@users.noreply.github.com> Date: Wed, 25 Dec 2024 06:09:45 +0000 Subject: [PATCH 3/3] update modal reverted --- ...ec.tsx => AgendaItemsUpdateModal.test.tsx} | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) rename src/components/AgendaItems/{AgendaItemsUpdateModal.spec.tsx => AgendaItemsUpdateModal.test.tsx} (96%) diff --git a/src/components/AgendaItems/AgendaItemsUpdateModal.spec.tsx b/src/components/AgendaItems/AgendaItemsUpdateModal.test.tsx similarity index 96% rename from src/components/AgendaItems/AgendaItemsUpdateModal.spec.tsx rename to src/components/AgendaItems/AgendaItemsUpdateModal.test.tsx index 8d277419fa..0f11ea31b2 100644 --- a/src/components/AgendaItems/AgendaItemsUpdateModal.spec.tsx +++ b/src/components/AgendaItems/AgendaItemsUpdateModal.test.tsx @@ -12,14 +12,13 @@ import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; import { store } from 'state/store'; import i18nForTest from 'utils/i18nForTest'; + import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import AgendaItemsUpdateModal from './AgendaItemsUpdateModal'; import { toast } from 'react-toastify'; import convertToBase64 from 'utils/convertToBase64'; -import type { MockedFunction } from 'vitest'; -import { describe, test, expect, vi } from 'vitest'; const mockFormState = { title: 'Test Title', @@ -68,19 +67,19 @@ const mockAgendaItemCategories = [ }, ]; -const mockHideUpdateModal = vi.fn(); -const mockSetFormState = vi.fn(); -const mockUpdateAgendaItemHandler = vi.fn(); +const mockHideUpdateModal = jest.fn(); +const mockSetFormState = jest.fn(); +const mockUpdateAgendaItemHandler = jest.fn(); const mockT = (key: string): string => key; -vi.mock('react-toastify', () => ({ +jest.mock('react-toastify', () => ({ toast: { - success: vi.fn(), - error: vi.fn(), + success: jest.fn(), + error: jest.fn(), }, })); -vi.mock('utils/convertToBase64'); -const mockedConvertToBase64 = convertToBase64 as MockedFunction< +jest.mock('utils/convertToBase64'); +const mockedConvertToBase64 = convertToBase64 as jest.MockedFunction< typeof convertToBase64 >;