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,52 @@
import { renderHook } from '@testing-library/react';
import { useInjectIntoActivityTargetInlineCellCache } from '@/activities/inline-cell/hooks/useInjectIntoActivityTargetInlineCellCache';
import { Activity } from '@/activities/types/Activity';
jest.mock('@/object-metadata/hooks/useObjectMetadataItemOnly', () => ({
useObjectMetadataItemOnly: jest.fn(() => ({
objectMetadataItem: { exampleMetadataItem: 'example' },
})),
}));
jest.mock(
'@/object-record/cache/hooks/useUpsertFindManyRecordsQueryInCache',
() => ({
useUpsertFindManyRecordsQueryInCache: jest.fn(() => ({
upsertFindManyRecordsQueryInCache: jest.fn(),
})),
}),
);
describe('useInjectIntoActivityTargetInlineCellCache', () => {
it('should inject into activity target inline cell cache as expected', () => {
const { result } = renderHook(() =>
useInjectIntoActivityTargetInlineCellCache(),
);
const { injectIntoActivityTargetInlineCellCache } = result.current;
const mockActivityId = 'mockId';
const mockActivityTargetsToInject = [
{
id: '1',
name: 'Example Activity Target',
createdAt: '2022-01-01',
updatedAt: '2022-01-01',
activity: {
id: '1',
createdAt: '2022-01-01',
updatedAt: '2022-01-01',
} as Pick<Activity, 'id' | 'createdAt' | 'updatedAt'>,
},
];
injectIntoActivityTargetInlineCellCache({
activityId: mockActivityId,
activityTargetsToInject: mockActivityTargetsToInject,
});
expect(
result.current.injectIntoActivityTargetInlineCellCache,
).toBeDefined();
});
});