Skip to content

Commit

Permalink
added tests for Attendance and Statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
duplixx committed Oct 30, 2024
1 parent 37ceafc commit 7d7083a
Show file tree
Hide file tree
Showing 7 changed files with 519 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@ import { EVENT_DETAILS } from 'GraphQl/Queries/Queries';
import { BrowserRouter } from 'react-router-dom';
import { I18nextProvider } from 'react-i18next';
import i18nForTest from 'utils/i18nForTest';
import { formatDate } from 'utils/dateFormatter';

const mockEvent = {
_id: 'event123',
title: 'Test Event',
startDate: '2023-06-15T10:00:00Z',
description: 'This is a test event description',
startDate: '2023-05-01',
endDate: '2023-05-02',
startTime: '09:00:00',
endTime: '17:00:00',
allDay: false,
location: 'Test Location',
recurring: true,
baseRecurringEvent: {
_id: 'recurringEvent123',
},
organization: {
_id: 'org456',
members: [
{ _id: 'member1', firstName: 'John', lastName: 'Doe' },
{ _id: 'member2', firstName: 'Jane', lastName: 'Smith' },
],
},
attendees: [{ _id: 'user1' }, { _id: 'user2' }],
};

const mocks = [
Expand Down Expand Up @@ -48,7 +66,7 @@ describe('Testing AttendedEventList', () => {

await waitFor(() => {
expect(queryByText('Test Event')).toBeInTheDocument();
expect(queryByText('Jun 15, 2023')).toBeInTheDocument();
expect(queryByText(formatDate(mockEvent.startDate))).toBeInTheDocument();
expect(queryByTitle('Event Date')).toBeInTheDocument();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@ interface InterfaceEventsAttended {
}

const AttendedEventList: React.FC<InterfaceEventsAttended> = ({ eventId }) => {
const { orgId: currentOrg } = useParams();
const { data, loading } = useQuery(EVENT_DETAILS, {
variables: { id: eventId },
});

if (loading) return <p>Loading...</p>;
const { orgId: currentOrg } = useParams();
const event = data?.event;

if (loading) return <p>Loading...</p>;

return (
<React.Fragment>
<Table className="bg-primary">
<TableBody className="bg-primary">
{event && (
<TableRow key={event._id} className="bg-white rounded">
<Link to={`/event/${currentOrg}/${event._id}`}>
<TableCell
style={{ color: 'blue' }}
<TableCell>
<Link
to={`/event/${currentOrg}/${event._id}`}
className="d-flex justify-items-center align-items-center"
style={{ color: 'blue', textDecoration: 'none' }}
>
<DateIcon
title="Event Date"
Expand All @@ -41,8 +43,8 @@ const AttendedEventList: React.FC<InterfaceEventsAttended> = ({ eventId }) => {
<div>{event.title}</div>
<div>{formatDate(event.startDate)}</div>
</div>
</TableCell>
</Link>
</Link>
</TableCell>
</TableRow>
)}
</TableBody>
Expand Down
Loading

0 comments on commit 7d7083a

Please sign in to comment.