diff --git a/client/src/hooks/Files/__tests__/useFileDeletion.spec.tsx b/client/src/hooks/Files/__tests__/useFileDeletion.spec.tsx new file mode 100644 index 0000000000..da084426c8 --- /dev/null +++ b/client/src/hooks/Files/__tests__/useFileDeletion.spec.tsx @@ -0,0 +1,135 @@ +import React, { useState } from 'react'; +import { FileSources, EToolResources } from 'librechat-data-provider'; +import { render, screen, act, renderHook } from '@testing-library/react'; +import type { ExtendedFile } from '~/common'; +import FileRow from '~/components/Chat/Input/Files/FileRow'; +import useFileDeletion from '../useFileDeletion'; + +const mockMutateAsync = jest.fn(); + +jest.mock('~/data-provider', () => ({ + useDeleteFilesMutation: () => ({ mutateAsync: mockMutateAsync }), +})); + +jest.mock('@librechat/client', () => ({ + useToastContext: () => ({ showToast: jest.fn() }), +})); + +jest.mock('~/hooks', () => ({ + useLocalize: () => (key: string) => key, +})); + +jest.mock('~/utils', () => ({ + ...jest.requireActual('~/utils'), + logger: { log: jest.fn() }, + getCachedPreview: () => undefined, + deletePreview: jest.fn(), +})); + +jest.mock('../useSetFilesToDelete', () => ({ + __esModule: true, + default: () => jest.fn(), +})); + +jest.mock('~/components/Chat/Input/Files/FileContainer', () => { + return function MockFileContainer({ + file, + onDelete, + }: { + file: ExtendedFile; + onDelete: () => void; + }) { + return