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:
@ -0,0 +1,45 @@
|
||||
import { renderHook } from '@testing-library/react';
|
||||
|
||||
import { useNotes } from '@/activities/notes/hooks/useNotes';
|
||||
import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity';
|
||||
|
||||
jest.mock('@/activities/hooks/useActivities', () => ({
|
||||
useActivities: jest.fn(() => ({
|
||||
activities: [{ id: '1', content: 'Example Note' }],
|
||||
initialized: true,
|
||||
loading: false,
|
||||
})),
|
||||
}));
|
||||
|
||||
jest.mock('recoil', () => {
|
||||
const actualRecoil = jest.requireActual('recoil');
|
||||
return {
|
||||
...actualRecoil,
|
||||
useRecoilState: jest.fn(() => {
|
||||
const mockCurrentNotesQueryVariables = {
|
||||
filter: {
|
||||
type: { eq: 'Note' },
|
||||
},
|
||||
orderBy: 'mockOrderBy',
|
||||
};
|
||||
return [mockCurrentNotesQueryVariables, jest.fn()];
|
||||
}),
|
||||
atom: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe('useNotes', () => {
|
||||
it('should return notes, initialized, and loading as expected', () => {
|
||||
const mockTargetableObject: ActivityTargetableObject = {
|
||||
id: '1',
|
||||
targetObjectNameSingular: 'Example Target',
|
||||
};
|
||||
const { result } = renderHook(() => useNotes(mockTargetableObject));
|
||||
|
||||
expect(result.current.notes).toEqual([
|
||||
{ id: '1', content: 'Example Note' },
|
||||
]);
|
||||
expect(result.current.initialized).toBe(true);
|
||||
expect(result.current.loading).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user