TWNTY-4450 - Add tests for /modules/activities/emails (#4520)
* Add tests for `/modules/activities/emails` Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Fix tests Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> * Remove temporary changes Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
This commit is contained in:
committed by
GitHub
parent
bdbd77c696
commit
872fb2bd49
@ -0,0 +1,53 @@
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
|
||||
import { useCalendarEvents } from '@/activities/calendar/hooks/useCalendarEvents';
|
||||
import { CalendarEvent } from '@/activities/calendar/types/CalendarEvent';
|
||||
|
||||
const calendarEvents: CalendarEvent[] = [
|
||||
{
|
||||
id: '1234',
|
||||
externalCreatedAt: '2024-02-17T20:45:43.854Z',
|
||||
isFullDay: false,
|
||||
startsAt: '2024-02-17T21:45:27.822Z',
|
||||
visibility: 'METADATA',
|
||||
},
|
||||
{
|
||||
id: '5678',
|
||||
externalCreatedAt: '2024-02-18T19:43:37.854Z',
|
||||
isFullDay: false,
|
||||
startsAt: '2024-02-18T21:43:27.754Z',
|
||||
visibility: 'SHARE_EVERYTHING',
|
||||
},
|
||||
{
|
||||
id: '91011',
|
||||
externalCreatedAt: '2024-02-19T20:45:20.854Z',
|
||||
isFullDay: true,
|
||||
startsAt: '2024-02-19T22:05:27.653Z',
|
||||
visibility: 'METADATA',
|
||||
},
|
||||
{
|
||||
id: '121314',
|
||||
externalCreatedAt: '2024-02-20T20:45:12.854Z',
|
||||
isFullDay: true,
|
||||
startsAt: '2024-02-20T23:15:23.150Z',
|
||||
visibility: 'SHARE_EVERYTHING',
|
||||
},
|
||||
];
|
||||
|
||||
describe('useCalendar', () => {
|
||||
it('returns calendar events', () => {
|
||||
const { result } = renderHook(() => useCalendarEvents(calendarEvents));
|
||||
|
||||
expect(result.current.currentCalendarEvent).toBe(calendarEvents[0]);
|
||||
|
||||
expect(result.current.getNextCalendarEvent(calendarEvents[1])).toBe(
|
||||
calendarEvents[0],
|
||||
);
|
||||
|
||||
act(() => {
|
||||
result.current.updateCurrentCalendarEvent();
|
||||
});
|
||||
|
||||
expect(result.current.currentCalendarEvent).toBe(calendarEvents[0]);
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,35 @@
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { RecoilRoot, useRecoilValue } from 'recoil';
|
||||
|
||||
import { useOpenCalendarEventRightDrawer } from '@/activities/calendar/right-drawer/hooks/useOpenCalendarEventRightDrawer';
|
||||
import { viewableCalendarEventIdState } from '@/activities/calendar/states/viewableCalendarEventIdState';
|
||||
import { isRightDrawerOpenState } from '@/ui/layout/right-drawer/states/isRightDrawerOpenState';
|
||||
|
||||
describe('useOpenCalendarEventRightDrawer', () => {
|
||||
it('opens the right drawer with the calendar event', () => {
|
||||
const { result } = renderHook(
|
||||
() => {
|
||||
const isRightDrawerOpen = useRecoilValue(isRightDrawerOpenState());
|
||||
const viewableCalendarEventId = useRecoilValue(
|
||||
viewableCalendarEventIdState(),
|
||||
);
|
||||
return {
|
||||
...useOpenCalendarEventRightDrawer(),
|
||||
isRightDrawerOpen,
|
||||
viewableCalendarEventId,
|
||||
};
|
||||
},
|
||||
{ wrapper: RecoilRoot },
|
||||
);
|
||||
|
||||
expect(result.current.isRightDrawerOpen).toBe(false);
|
||||
expect(result.current.viewableCalendarEventId).toBeNull();
|
||||
|
||||
act(() => {
|
||||
result.current.openCalendarEventRightDrawer('1234');
|
||||
});
|
||||
|
||||
expect(result.current.isRightDrawerOpen).toBe(true);
|
||||
expect(result.current.viewableCalendarEventId).toBe('1234');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user