Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: jest to vitest : Fixes #2547 #2641

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Testing component for managing and displaying Volunteer Membership requests for an event.
*
* This component allows users to view, filter, sort, and create action items. It also allows users to accept or reject volunteer membership requests.
*
*
*/
import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
import { LocalizationProvider } from '@mui/x-date-pickers';
Expand All @@ -20,11 +27,12 @@ import {
UPDATE_ERROR_MOCKS,
} from './Requests.mocks';
import { toast } from 'react-toastify';
import { vi } from 'vitest';

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

Expand Down Expand Up @@ -74,14 +82,14 @@ const renderRequests = (link: ApolloLink): RenderResult => {

describe('Testing Requests Screen', () => {
beforeAll(() => {
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
vi.mock('react-router-dom', async () => ({
...(await vi.importActual('react-router-dom')),
useParams: () => ({ orgId: 'orgId', eventId: 'eventId' }),
}));
});

afterAll(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});

it('should redirect to fallback URL if URL params are undefined', async () => {
Expand All @@ -92,10 +100,7 @@ describe('Testing Requests Screen', () => {
<I18nextProvider i18n={i18n}>
<Routes>
<Route path="/event/" element={<Requests />} />
<Route
path="/"
element={<div data-testid="paramsError"></div>}
/>
<Route path="/" element={<Requests />} />
</Routes>
</I18nextProvider>
</Provider>
Expand All @@ -104,7 +109,7 @@ describe('Testing Requests Screen', () => {
);

await waitFor(() => {
expect(screen.getByTestId('paramsError')).toBeInTheDocument();
expect(window.location.pathname).toBe('/');
});
});

Expand Down
Loading