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

Refactored src/screens/UserPortal/Volunteer/Invitations from jest to vitest #2691

Closed
34 changes: 18 additions & 16 deletions src/components/CheckIn/tagTemplate.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,24 @@ import {
} from './Invitations.mocks';
import { toast } from 'react-toastify';
import useLocalStorage from 'utils/useLocalstorage';
import { vi, expect } from 'vitest';

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

vi.mock('react-router-dom', async () => {
const actual = await vi.importActual('react-router-dom');
return {
...actual,
useParams: () => ({ orgId: 'orgId' }),
useNavigate: vi.fn(),
};
});

const { setItem } = useLocalStorage();

const link1 = new StaticMockLink(MOCKS);
Expand Down Expand Up @@ -79,19 +89,12 @@ const renderInvitations = (link: ApolloLink): RenderResult => {
};

describe('Testing Invvitations Screen', () => {
beforeAll(() => {
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useParams: () => ({ orgId: 'orgId' }),
}));
});

beforeEach(() => {
setItem('userId', 'userId');
});

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

it('should redirect to fallback URL if URL params are undefined', async () => {
Expand Down
Loading