Skip to content

Commit

Permalink
Migrated src/components/AgendaItems/* from Jest to Vitest (#2850)
Browse files Browse the repository at this point in the history
* Update Agenda items vitest

* Update jest to vitest

* update modal reverted
  • Loading branch information
mandeepnh5 authored Dec 25, 2024
1 parent 00216ba commit f8da9d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/AgendaItems/AgendaItemsContainerProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type AgendaItemConnectionType = 'Event';
import { vi } from 'vitest';

export const props = {
agendaItemConnection: 'Event' as AgendaItemConnectionType,
Expand Down Expand Up @@ -68,7 +69,7 @@ export const props = {
},
},
],
agendaItemRefetch: jest.fn(),
agendaItemRefetch: vi.fn(),
agendaItemCategories: [
{
_id: 'agendaCategory1',
Expand Down Expand Up @@ -96,6 +97,6 @@ export const props = {
export const props2 = {
agendaItemConnection: 'Event' as AgendaItemConnectionType,
agendaItemData: [],
agendaItemRefetch: jest.fn(),
agendaItemRefetch: vi.fn(),
agendaItemCategories: [],
};
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -44,10 +45,10 @@ describe('AgendaItemsPreviewModal', () => {
<LocalizationProvider dateAdapter={AdapterDayjs}>
<AgendaItemsPreviewModal
agendaItemPreviewModalIsOpen
hidePreviewModal={jest.fn()}
hidePreviewModal={vi.fn()}
formState={mockFormState}
showUpdateModal={jest.fn()}
toggleDeleteModal={jest.fn()}
showUpdateModal={vi.fn()}
toggleDeleteModal={vi.fn()}
t={mockT}
/>
</LocalizationProvider>
Expand Down

0 comments on commit f8da9d5

Please sign in to comment.