diff --git a/src/components/MemberDetail/EventsAttendedMemberModal.test.tsx b/src/components/MemberDetail/EventsAttendedMemberModal.test.tsx
index c7509cedac..7a9698a155 100644
--- a/src/components/MemberDetail/EventsAttendedMemberModal.test.tsx
+++ b/src/components/MemberDetail/EventsAttendedMemberModal.test.tsx
@@ -4,45 +4,56 @@ import { MockedProvider } from '@apollo/client/testing';
import { BrowserRouter } from 'react-router-dom';
import EventsAttendedMemberModal from './EventsAttendedMemberModal';
+// Mock translations
jest.mock('react-i18next', () => ({
- useTranslation: () => ({ t: (key: string) => key }),
+ useTranslation: () => ({
+ t: (key: string) => key,
+ i18n: { changeLanguage: () => Promise.resolve() },
+ }),
}));
-const mockEvents = [
- { _id: 'event1' },
- { _id: 'event2' },
- { _id: 'event3' },
- { _id: 'event4' },
- { _id: 'event5' },
- { _id: 'event6' },
-];
-
-describe('MemberAttendedEventsModal', () => {
- it('renders modal when show is true', () => {
+// Mock event data
+const mockEvents = Array.from({ length: 6 }, (_, index) => ({
+ _id: `event${index + 1}`,
+ name: `Event ${index + 1}`,
+ date: new Date().toISOString().split('T')[0],
+ isRecurring: false,
+ attendees: 5,
+ description: `Description ${index + 1}`,
+ location: `Location ${index + 1}`,
+ startTime: '10:00',
+ endTime: '11:00',
+}));
+
+describe('EventsAttendedMemberModal', () => {
+ const defaultProps = {
+ eventsAttended: mockEvents,
+ setShow: jest.fn(),
+ show: true,
+ };
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ test('renders modal with correct title when show is true', () => {
render(
- {}}
- show={true}
- />
+
,
);
expect(screen.getByText('Events Attended List')).toBeInTheDocument();
+ expect(screen.getByText('Showing 1 - 5 of 6 Events')).toBeInTheDocument();
});
- it('displays no events message when eventsAttended is empty', () => {
+ test('displays empty state message when no events', () => {
render(
- {}}
- show={true}
- />
+
,
);
@@ -50,54 +61,60 @@ describe('MemberAttendedEventsModal', () => {
expect(screen.getByText('noeventsAttended')).toBeInTheDocument();
});
- it('renders correct number of events per page', () => {
+ test('renders correct number of events per page', () => {
render(
- {}}
- show={true}
- />
+
,
);
- expect(screen.getAllByTestId('custom-row')).toHaveLength(5);
+ const eventRows = screen.getAllByTestId('custom-row');
+ expect(eventRows).toHaveLength(5);
+ expect(screen.getByText('Event 1')).toBeInTheDocument();
+ expect(screen.getByText('Event 5')).toBeInTheDocument();
});
- it('updates page when pagination is clicked', () => {
+ test('handles pagination correctly', () => {
render(
- {}}
- show={true}
- />
+
,
);
fireEvent.click(screen.getByRole('button', { name: '2' }));
- expect(screen.getByText('Showing 1 - 5 of 6 Events')).toBeInTheDocument();
+ expect(screen.getByText('Event 6')).toBeInTheDocument();
});
- it('calls setShow when close button is clicked', () => {
+ test('closes modal when close button is clicked', () => {
const mockSetShow = jest.fn();
render(
-
+
,
);
fireEvent.click(screen.getByRole('button', { name: 'Close' }));
expect(mockSetShow).toHaveBeenCalledWith(false);
+ expect(mockSetShow).toHaveBeenCalledTimes(1);
+ });
+
+ test('displays correct pagination info', () => {
+ render(
+
+
+
+
+ ,
+ );
+
+ expect(screen.getByText('Showing 1 - 5 of 6 Events')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: '2' }));
+ expect(screen.getByText('Showing 6 - 6 of 6 Events')).toBeInTheDocument();
});
});
diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx
index 3ea0c3230e..77516ddc7a 100644
--- a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx
+++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import { act } from '@testing-library/react';
-import { fireEvent, render, screen } from '@testing-library/react';
+import { act, fireEvent, render, screen } from '@testing-library/react';
+
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
diff --git a/src/screens/EventManagement/EventManagement.tsx b/src/screens/EventManagement/EventManagement.tsx
index 2c23faa87e..b4e0373bcf 100644
--- a/src/screens/EventManagement/EventManagement.tsx
+++ b/src/screens/EventManagement/EventManagement.tsx
@@ -152,9 +152,8 @@ const EventManagement = (): JSX.Element => {
const handleBack = (): void => {
/*istanbul ignore next*/
- userRole === 'USER'
- ? navigate(`/user/events/${orgId}`)
- : navigate(`/orgevents/${orgId}`);
+ const route = userRole === 'USER' ? 'user/events' : 'orgevents';
+ navigate(`/${route}/${orgId}`);
};
return (
@@ -197,7 +196,7 @@ const EventManagement = (): JSX.Element => {
/* istanbul ignore next */
() => setTab(value)
}
- className={`d-flex gap-2 ${tab === value && 'text-secondary'}`}
+ className={`d-flex gap-2 ${tab === value ? 'text-secondary' : ''}`}
>
{icon} {t(value)}
@@ -250,10 +249,11 @@ const EventManagement = (): JSX.Element => {
Event Statistics
);
+ default:
+ return null;
}
})()}
);
};
-
export default EventManagement;
diff --git a/src/screens/MemberDetail/MemberDetail.test.tsx b/src/screens/MemberDetail/MemberDetail.test.tsx
index eaea79d8c5..fc2d5a3c16 100644
--- a/src/screens/MemberDetail/MemberDetail.test.tsx
+++ b/src/screens/MemberDetail/MemberDetail.test.tsx
@@ -16,7 +16,6 @@ import { USER_DETAILS } from 'GraphQl/Queries/Queries';
import i18nForTest from 'utils/i18nForTest';
import { StaticMockLink } from 'utils/StaticMockLink';
import MemberDetail, { getLanguageName, prettyDate } from './MemberDetail';
-import { toast } from 'react-toastify';
const MOCKS1 = [
{
diff --git a/src/screens/UserPortal/Settings/Settings.test.tsx b/src/screens/UserPortal/Settings/Settings.test.tsx
index cc743a0328..e43ad77f02 100644
--- a/src/screens/UserPortal/Settings/Settings.test.tsx
+++ b/src/screens/UserPortal/Settings/Settings.test.tsx
@@ -109,33 +109,6 @@ const Mocks2 = [
},
];
-const mockMaritalStatusEnum = [
- {
- value: 'SINGLE',
- label: 'Single',
- },
- {
- value: 'ENGAGED',
- label: 'Engaged',
- },
- {
- value: 'MARRIED',
- label: 'Married',
- },
- {
- value: 'DIVORCED',
- label: 'Divorced',
- },
- {
- value: 'WIDOWED',
- label: 'Widowed',
- },
- {
- value: 'SEPARATED',
- label: 'Separated',
- },
-];
-
const link = new StaticMockLink(MOCKS, true);
const link1 = new StaticMockLink(Mocks1, true);
const link2 = new StaticMockLink(Mocks2, true);