From 73c4fdb7060e7676fecff6f479fac04ce2437d1f Mon Sep 17 00:00:00 2001 From: Ramneet04 Date: Mon, 23 Dec 2024 00:46:10 +0530 Subject: [PATCH 1/7] file name changed --- ...aItemsCreateModal.test.tsx => AgendaItemsCreateModal.spec.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/components/AgendaItems/{AgendaItemsCreateModal.test.tsx => AgendaItemsCreateModal.spec.tsx} (100%) diff --git a/src/components/AgendaItems/AgendaItemsCreateModal.test.tsx b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx similarity index 100% rename from src/components/AgendaItems/AgendaItemsCreateModal.test.tsx rename to src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx From 7372ebd762ae78de8f014780dbeff5b076807097 Mon Sep 17 00:00:00 2001 From: Ramneet04 Date: Mon, 23 Dec 2024 00:50:07 +0530 Subject: [PATCH 2/7] migrate jest to vitest --- .../AgendaItemsCreateModal.spec.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx index 5b7339ad67..965650a841 100644 --- a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx +++ b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx @@ -20,6 +20,9 @@ import AgendaItemsCreateModal from './AgendaItemsCreateModal'; import { toast } from 'react-toastify'; import convertToBase64 from 'utils/convertToBase64'; +import '@testing-library/jest-dom'; +import { describe, test, expect, vi } from 'vitest'; + const mockFormState = { title: 'Test Title', description: 'Test Description', @@ -28,9 +31,9 @@ const mockFormState = { urls: ['https://example.com'], agendaItemCategoryIds: ['category'], }; -const mockHideCreateModal = jest.fn(); -const mockSetFormState = jest.fn(); -const mockCreateAgendaItemHandler = jest.fn(); +const mockHideCreateModal = vi.fn(); +const mockSetFormState = vi.fn(); +const mockCreateAgendaItemHandler = vi.fn(); const mockT = (key: string): string => key; const mockAgendaItemCategories = [ { @@ -64,14 +67,14 @@ const mockAgendaItemCategories = [ }, }, ]; -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 vi.MockedFunction< typeof convertToBase64 >; From 36a504b89553acc28cb81e30ca036c5e101dd1f0 Mon Sep 17 00:00:00 2001 From: Ramneet04 Date: Mon, 23 Dec 2024 03:02:27 +0530 Subject: [PATCH 3/7] changes done --- src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx index 965650a841..73cf50ee6b 100644 --- a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx +++ b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx @@ -74,7 +74,7 @@ vi.mock('react-toastify', () => ({ }, })); vi.mock('utils/convertToBase64'); -const mockedConvertToBase64 = convertToBase64 as vi.MockedFunction< +const mockedConvertToBase64 = convertToBase64 as import('vitest').MockedFunction< typeof convertToBase64 >; From 027936d88197c73057aef63ef67eab3ec9c876c2 Mon Sep 17 00:00:00 2001 From: Ramneet04 Date: Mon, 23 Dec 2024 22:25:32 +0530 Subject: [PATCH 4/7] formated the code --- src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx index 73cf50ee6b..bd9a8f8765 100644 --- a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx +++ b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx @@ -74,9 +74,8 @@ vi.mock('react-toastify', () => ({ }, })); vi.mock('utils/convertToBase64'); -const mockedConvertToBase64 = convertToBase64 as import('vitest').MockedFunction< - typeof convertToBase64 ->; +const mockedConvertToBase64 = + convertToBase64 as import('vitest').MockedFunction; describe('AgendaItemsCreateModal', () => { test('renders modal correctly', () => { From 3a2dc11463f1d1adbdf3d9fdce7288224f2acd81 Mon Sep 17 00:00:00 2001 From: Ramneet04 Date: Mon, 23 Dec 2024 22:36:35 +0530 Subject: [PATCH 5/7] fixed the type error --- src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx index bd9a8f8765..ce0f675ec5 100644 --- a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx +++ b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx @@ -19,6 +19,7 @@ import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import AgendaItemsCreateModal from './AgendaItemsCreateModal'; import { toast } from 'react-toastify'; import convertToBase64 from 'utils/convertToBase64'; +import type { MockedFunction } from 'vitest'; import '@testing-library/jest-dom'; import { describe, test, expect, vi } from 'vitest'; @@ -74,8 +75,9 @@ vi.mock('react-toastify', () => ({ }, })); vi.mock('utils/convertToBase64'); -const mockedConvertToBase64 = - convertToBase64 as import('vitest').MockedFunction; +const mockedConvertToBase64 = convertToBase64 as MockedFunction< + typeof convertToBase64 +>; describe('AgendaItemsCreateModal', () => { test('renders modal correctly', () => { From 75562f3c1fe65e7cc7256240c8dab679a74df584 Mon Sep 17 00:00:00 2001 From: Ramneet04 Date: Tue, 24 Dec 2024 00:35:44 +0530 Subject: [PATCH 6/7] removed @testing-library/jest-dom --- src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx index ce0f675ec5..abdf528299 100644 --- a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx +++ b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx @@ -21,7 +21,6 @@ import { toast } from 'react-toastify'; import convertToBase64 from 'utils/convertToBase64'; import type { MockedFunction } from 'vitest'; -import '@testing-library/jest-dom'; import { describe, test, expect, vi } from 'vitest'; const mockFormState = { From 8311f6c11b3baa92813e1c62ec3d9970178ff692 Mon Sep 17 00:00:00 2001 From: Ramneet04 Date: Tue, 24 Dec 2024 00:44:06 +0530 Subject: [PATCH 7/7] @testing-library/jest-dom removed --- src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx index abdf528299..35ea8c7681 100644 --- a/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx +++ b/src/components/AgendaItems/AgendaItemsCreateModal.spec.tsx @@ -20,7 +20,6 @@ import AgendaItemsCreateModal from './AgendaItemsCreateModal'; import { toast } from 'react-toastify'; import convertToBase64 from 'utils/convertToBase64'; import type { MockedFunction } from 'vitest'; - import { describe, test, expect, vi } from 'vitest'; const mockFormState = {