Skip to content

Commit

Permalink
fix: scrollbar removed, added test for day viewType, corrected change…
Browse files Browse the repository at this point in the history
… viewType in values in EventHeader
  • Loading branch information
PratapRathi committed Jan 22, 2025
1 parent 42303cb commit 940dba4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
7 changes: 7 additions & 0 deletions src/components/EventCalendar/EventCalendar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,11 @@ describe('Calendar', () => {
});
});
});
it('render the hour view', async () => {
render(<Calendar eventData={eventData} viewType={ViewType.DAY} />);

await wait();
const renderHourComponent = screen.getByTestId('hour');
expect(renderHourComponent).toBeInTheDocument();
});
});
17 changes: 3 additions & 14 deletions src/components/EventCalendar/EventCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,7 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
events
?.filter((datas) => {
const currDate = new Date(currentYear, currentMonth, currentDate);
if (
datas.startTime == undefined &&
datas.startDate == dayjs(currDate).format('YYYY-MM-DD')
) {
if (datas.startDate == dayjs(currDate).format('YYYY-MM-DD')) {
return datas;
}
})
Expand Down Expand Up @@ -296,7 +293,7 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({

return (
<>
<div className={styles.calendar_hour_block}>
<div className={styles.calendar_hour_block} data-testid="hour">
<div className={styles.calendar_hour_text_container}>
<p className={styles.calendar_timezone_text}>{timezoneString}</p>
</div>
Expand Down Expand Up @@ -571,7 +568,7 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
</div>
</div>
)}
<div className={`${styles.calendar__scroll} customScroll`}>
<div>
{viewType == ViewType.MONTH ? (
<>
<div className={styles.calendar__weekdays}>
Expand All @@ -589,14 +586,6 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
<div className={styles.calendar__hours}>{renderHours()}</div>
)}
</div>

<div>
{viewType == ViewType.YEAR ? (
<YearlyEventCalender eventData={eventData} />
) : (
<div className={styles.calendar__hours}>{renderHours()}</div>
)}
</div>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/EventCalendar/EventHeader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('EventHeader Component', () => {
fireEvent.click(getByTestId('selectViewType'));

await act(async () => {
fireEvent.click(getByTestId('selectDay'));
fireEvent.click(getByTestId('Day'));
});

// Expect handleChangeView to be called with the new view type
Expand Down
6 changes: 3 additions & 3 deletions src/components/EventCalendar/EventHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ function eventHeader({
<SortingButton
title={t('viewType')}
sortingOptions={[
{ label: ViewType.MONTH, value: 'selectMonth' },
{ label: ViewType.DAY, value: 'selectDay' },
{ label: ViewType.YEAR, value: 'selectYear' },
{ label: 'Select Month', value: ViewType.MONTH },
{ label: 'Select Day', value: ViewType.DAY },
{ label: 'Select Year', value: ViewType.YEAR },
]}
selectedOption={viewType}
onSortChange={handleChangeView}
Expand Down

0 comments on commit 940dba4

Please sign in to comment.