Skip to content

Commit

Permalink
Update EventRegistryModal jest to vitest (#2910)
Browse files Browse the repository at this point in the history
  • Loading branch information
mandeepnh5 authored Dec 26, 2024
1 parent 35cce16 commit 895bead
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@ import { Provider } from 'react-redux';
import { I18nextProvider } from 'react-i18next';
import { store } from 'state/store';
import i18nForTest from '../../utils/i18nForTest';
import { describe, expect, vi } from 'vitest';

jest.mock('react-toastify', () => ({
vi.mock('react-toastify', () => ({
toast: {
success: jest.fn(),
error: jest.fn(),
success: vi.fn(),
error: vi.fn(),
},
}));

const mockProps = {
show: true,
handleClose: jest.fn(),
reloadMembers: jest.fn(),
handleClose: vi.fn(),
reloadMembers: vi.fn(),
};
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useParams: () => ({ eventId: '123', orgId: '123' }),
}));
vi.mock('react-router-dom', async () => {
const actual = await vi.importActual('react-router-dom');
return {
...actual,
useParams: () => ({ eventId: '123', orgId: '123' }),
};
});

const MOCKS = [
{
Expand Down Expand Up @@ -80,7 +84,7 @@ const renderAddOnSpotAttendee = (): RenderResult => {

describe('AddOnSpotAttendee Component', () => {
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});

it('renders the component with all form fields', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import i18nForTest from 'utils/i18nForTest';
import { ToastContainer } from 'react-toastify';
import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { describe, test, expect, vi } from 'vitest';

const queryMockWithoutRegistrant = [
{
Expand Down Expand Up @@ -160,7 +161,7 @@ describe('Testing Event Registrants Modal', () => {
show: true,
eventId: 'event123',
orgId: 'org123',
handleClose: jest.fn(),
handleClose: vi.fn(),
};

test('The modal should be rendered, correct text must be displayed when there are no attendees and add attendee mutation must function properly', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import i18nForTest from 'utils/i18nForTest';
import { ToastContainer } from 'react-toastify';
import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { describe, test, expect } from 'vitest';

const queryMock = [
{
Expand Down

0 comments on commit 895bead

Please sign in to comment.