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: src/screens/OrganizationVenues from Jest to Vitest #2665

Open
wants to merge 16 commits into
base: develop-postgres
Choose a base branch
from
Open
Changes from 4 commits
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
Expand Up @@ -10,7 +10,6 @@ import {
} from '@testing-library/react';
import { Provider } from 'react-redux';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import 'jest-location-mock';
import { I18nextProvider } from 'react-i18next';
import OrganizationVenues from './OrganizationVenues';
import { store } from 'state/store';
Expand All @@ -19,7 +18,7 @@ import { StaticMockLink } from 'utils/StaticMockLink';
import { VENUE_LIST } from 'GraphQl/Queries/OrganizationQueries';
import type { ApolloLink } from '@apollo/client';
import { DELETE_VENUE_MUTATION } from 'GraphQl/Mutations/VenueMutations';

import { vi } from 'vitest';
const MOCKS = [
{
request: {
Expand Down Expand Up @@ -239,11 +238,11 @@ async function wait(ms = 100): Promise<void> {
});
}

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

Expand Down Expand Up @@ -272,14 +271,14 @@ const renderOrganizationVenue = (link: ApolloLink): RenderResult => {

describe('OrganizationVenue with missing orgId', () => {
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: undefined }),
}));
});

afterAll(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});
test('Redirect to /orglist when orgId is falsy/undefined', async () => {
render(
Expand Down Expand Up @@ -308,17 +307,17 @@ describe('OrganizationVenue with missing orgId', () => {
});

describe('Organisation Venues', () => {
global.alert = jest.fn();
global.alert = vi.fn();

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' }),
}));
});

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

test('searches the venue list correctly by Name', async () => {
Expand Down
Loading