Skip to content

Commit

Permalink
refactor:vitest to src/components/MemberDetail/* (#2945)
Browse files Browse the repository at this point in the history
  • Loading branch information
shivasankaran18 authored Dec 26, 2024
1 parent a12833b commit 9fdba79
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom';
import EventAttendedCard from './EventsAttendedCardItem';
import { vi } from 'vitest';

interface InterfaceEventAttendedCardProps {
type: 'Event';
Expand Down Expand Up @@ -33,7 +34,7 @@ describe('EventAttendedCard', () => {
};

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

it('renders event details correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@ import { render, screen, fireEvent } from '@testing-library/react';
import { MockedProvider } from '@apollo/client/testing';
import { BrowserRouter } from 'react-router-dom';
import EventsAttendedMemberModal from './EventsAttendedMemberModal';
import { vi } from 'vitest';

jest.mock('react-i18next', () => ({
/**
* Mock the `react-i18next` module to provide translation functionality.
*/

vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
i18n: { changeLanguage: () => Promise.resolve() },
}),
}));

jest.mock('./customTableCell', () => ({
/**
* Mock the `CustomTableCell` component for testing.
*/

vi.mock('./customTableCell', () => ({
CustomTableCell: ({ eventId }: { eventId: string }) => (
<tr data-testid="event-row">
<td>{`Event ${eventId}`}</td>
Expand All @@ -33,12 +42,12 @@ const mockEvents = Array.from({ length: 6 }, (_, index) => ({
describe('EventsAttendedMemberModal', () => {
const defaultProps = {
eventsAttended: mockEvents,
setShow: jest.fn(),
setShow: vi.fn(),
show: true,
};

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

test('renders modal with correct title when show is true', () => {
Expand Down Expand Up @@ -95,7 +104,7 @@ describe('EventsAttendedMemberModal', () => {
});

test('closes modal when close button is clicked', () => {
const mockSetShow = jest.fn();
const mockSetShow = vi.fn();
render(
<MockedProvider>
<BrowserRouter>
Expand Down

0 comments on commit 9fdba79

Please sign in to comment.