diff --git a/src/components/EventCalendar/EventCalendar.tsx b/src/components/EventCalendar/EventCalendar.tsx index 397df845fb0..01426ca0474 100644 --- a/src/components/EventCalendar/EventCalendar.tsx +++ b/src/components/EventCalendar/EventCalendar.tsx @@ -348,7 +348,7 @@ const Calendar: React.FC = ({ {months[parseInt(holiday.date.slice(0, 2), 10) - 1]}{' '} {holiday.date.slice(3)} - {holiday.name} + {holiday.name} ))} @@ -357,21 +357,15 @@ const Calendar: React.FC = ({

Events

-
- - Holidays -
Events Created by Organization
-
- - - Events Created by User - +
+ + Holidays
@@ -519,34 +513,36 @@ const Calendar: React.FC = ({
{viewType != ViewType.YEAR && (
- +
+ -
- {viewType == ViewType.DAY ? `${currentDate}` : ``} {currentYear}{' '} -
{months[currentMonth]}
+
+ {viewType == ViewType.DAY ? `${currentDate}` : ``} {currentYear}{' '} +
{months[currentMonth]}
+
+
-
-
+ {/*
*/}
- +
+ +
diff --git a/src/components/EventCalendar/constants.js b/src/components/EventCalendar/constants.js index f2b770426c9..3cacad758ae 100644 --- a/src/components/EventCalendar/constants.js +++ b/src/components/EventCalendar/constants.js @@ -13,7 +13,15 @@ export const holidays = [ }, { name: 'Christmas Day', date: '12-25', month: 'December' }, // December 25th ]; -export const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +export const weekdays = [ + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday', +]; export const months = [ 'January', 'February', diff --git a/src/components/HolidayCards/HolidayCard.module.css b/src/components/HolidayCards/HolidayCard.module.css deleted file mode 100644 index c7686ab8702..00000000000 --- a/src/components/HolidayCards/HolidayCard.module.css +++ /dev/null @@ -1,12 +0,0 @@ -.card { - background-color: #b4dcb7; - font-size: 14px; - font-weight: 400; - display: flex; - padding: 8px 4px; - border-radius: 5px; - margin-bottom: 4px; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; -} diff --git a/src/components/HolidayCards/HolidayCard.spec.tsx b/src/components/HolidayCards/HolidayCard.spec.tsx new file mode 100644 index 00000000000..cb865a267b8 --- /dev/null +++ b/src/components/HolidayCards/HolidayCard.spec.tsx @@ -0,0 +1,51 @@ +import React from 'react'; +import { describe, test, expect } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import HolidayCard from './HolidayCard'; +import styles from './../../style/app.module.css'; + +describe('HolidayCard Component', () => { + test('renders without crashing', () => { + render(); + expect(screen.getByTestId('holiday-card')).toBeDefined(); + }); + + test('displays the provided holiday name', () => { + const testHolidayName = 'New Year'; + render(); + + const cardElement = screen.getByTestId('holiday-card'); + expect(cardElement.textContent).toBe(testHolidayName); + }); + + test('applies the correct CSS class', () => { + render(); + + const cardElement = screen.getByTestId('holiday-card'); + expect(cardElement.className).toBe(styles.holidayCard); + }); + + test('handles empty holiday name', () => { + render(); + + const cardElement = screen.getByTestId('holiday-card'); + expect(cardElement.textContent).toBe(''); + }); + + test('handles long holiday names', () => { + const longHolidayName = 'International Talk Like a Pirate Day Celebration'; + render(); + + const cardElement = screen.getByTestId('holiday-card'); + expect(cardElement.textContent).toBe(longHolidayName); + }); + + // TypeScript compile-time tests + test('TypeScript props validation', () => { + // @ts-expect-error - Testing TypeScript validation for missing required prop + render(); + + // @ts-expect-error - Testing TypeScript validation for wrong prop type + render(); + }); +}); diff --git a/src/components/HolidayCards/HolidayCard.tsx b/src/components/HolidayCards/HolidayCard.tsx index 56ac86405da..5bcc9f95f5b 100644 --- a/src/components/HolidayCards/HolidayCard.tsx +++ b/src/components/HolidayCards/HolidayCard.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import styles from './HolidayCard.module.css'; +import styles from './../../style/app.module.css'; // Props for the HolidayCard component interface InterfaceHolidayList { @@ -13,8 +13,11 @@ interface InterfaceHolidayList { * @returns JSX element representing a card with the holiday name. */ const HolidayCard = (props: InterfaceHolidayList): JSX.Element => { - /*istanbul ignore next*/ - return
{props?.holidayName}
; + return ( +
+ {props?.holidayName} +
+ ); }; export default HolidayCard; diff --git a/src/screens/UserPortal/Events/Events.spec.tsx b/src/screens/UserPortal/Events/Events.spec.tsx index 0e494020197..86d257a9371 100644 --- a/src/screens/UserPortal/Events/Events.spec.tsx +++ b/src/screens/UserPortal/Events/Events.spec.tsx @@ -650,7 +650,7 @@ describe('Testing Events Screen [User Portal]', () => { const calenderView = 'Calendar View'; expect(screen.queryAllByText(calenderView)).not.toBeNull(); - expect(screen.getByText('Sun')).toBeInTheDocument(); + expect(screen.getByText('Sunday')).toBeInTheDocument(); }); it('Testing DatePicker and TimePicker', async () => { diff --git a/src/screens/UserPortal/Events/Events.tsx b/src/screens/UserPortal/Events/Events.tsx index a6862c0a731..2e3cadedc3d 100644 --- a/src/screens/UserPortal/Events/Events.tsx +++ b/src/screens/UserPortal/Events/Events.tsx @@ -121,8 +121,6 @@ export default function events(): JSX.Element { createChat: createChatCheck, }, }); - - /* istanbul ignore next */ if (createEventData) { toast.success(t('eventCreated') as string); refetch(); @@ -137,7 +135,6 @@ export default function events(): JSX.Element { setCreateEventmodalisOpen(false); } catch (error: unknown) { console.error('create event error', error); - /* istanbul ignore next */ errorHandler(t, error); } }; @@ -147,7 +144,6 @@ export default function events(): JSX.Element { * * @returns Void. */ - /* istanbul ignore next */ const toggleCreateEventModal = (): void => setCreateEventmodalisOpen(!createEventModal); @@ -188,7 +184,6 @@ export default function events(): JSX.Element { }; // Update the list of events when the data from the query changes - /* istanbul ignore next */ React.useEffect(() => { if (data) { setEvents(data.eventsByOrganizationConnection); @@ -200,7 +195,6 @@ export default function events(): JSX.Element { * * @returns Void. */ - /* istanbul ignore next */ const showInviteModal = (): void => { setCreateEventmodalisOpen(true); }; @@ -211,9 +205,7 @@ export default function events(): JSX.Element { * @param item - The view type to set, or null to reset. * @returns Void. */ - /* istanbul ignore next */ const handleChangeView = (item: string | null): void => { - /*istanbul ignore next*/ if (item) { setViewType(item as ViewType); } @@ -222,7 +214,7 @@ export default function events(): JSX.Element { return ( <>
-
+