First batch of modules/activities tests (#4446)

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>
Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
This commit is contained in:
gitstart-twenty
2024-03-15 12:32:06 -03:00
committed by GitHub
parent 7b83c84fa5
commit c083bb15cd
9 changed files with 428 additions and 0 deletions

View File

@ -0,0 +1,38 @@
import { renderHook } from '@testing-library/react';
import { RecoilRoot } from 'recoil';
import { useActivityById } from '../useActivityById';
jest.mock('@/object-record/hooks/useFindOneRecord', () => ({
useFindOneRecord: jest.fn(() => ({
record: {
activity: {
id: 'test-activity-id',
name: 'Test Activity',
description: 'This is a test activity',
},
},
loading: false,
})),
}));
describe('useActivityById', () => {
it('fetches activity by id and returns the activity and loading state', async () => {
const activityId = 'test-activity-id';
const { result } = renderHook(() => useActivityById({ activityId }), {
wrapper: RecoilRoot,
});
expect(result.current.loading).toBe(false);
expect(result.current.activity).toEqual({
activity: {
id: 'test-activity-id',
name: 'Test Activity',
description: 'This is a test activity',
},
activityTargets: [],
comments: [],
});
});
});