mirror of
https://git.um-react.app/um/um-react.git
synced 2026-10-27 00:43:01 +00:00
chore: dep pkg upgrade
- Updated Node version in Dockerfile and .npmrc. - Upgraded various dependencies in package.json, including react-dropzone, react-router, and eslint. - Added pnpm-workspace.yaml for workspace management. - Adjusted TypeScript configurations and test utilities for compatibility. - Enhanced documentation for installation instructions and TypeScript toolchain.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { FileInput } from '../FileInput';
|
||||
|
||||
test('receives multiple files from the file picker', async () => {
|
||||
const onReceiveFiles = vi.fn();
|
||||
const files = [new File(['first'], 'first.qmc3'), new File(['second'], 'second.mflac')];
|
||||
const { container } = render(<FileInput onReceiveFiles={onReceiveFiles}>Choose files</FileInput>);
|
||||
const input = container.querySelector('input');
|
||||
if (!input) throw new Error('File input is missing');
|
||||
|
||||
await userEvent.upload(input, files);
|
||||
|
||||
await waitFor(() => expect(onReceiveFiles).toHaveBeenCalledOnce());
|
||||
expect(onReceiveFiles.mock.calls[0][0]).toEqual(files);
|
||||
});
|
||||
|
||||
test('receives multiple dropped files', async () => {
|
||||
const onReceiveFiles = vi.fn();
|
||||
const files = [new File(['first'], 'first.kgm'), new File(['second'], 'second.ncm')];
|
||||
render(<FileInput onReceiveFiles={onReceiveFiles}>Drop files</FileInput>);
|
||||
|
||||
fireEvent.drop(screen.getByText('Drop files'), {
|
||||
dataTransfer: {
|
||||
files,
|
||||
items: files.map((file) => ({ kind: 'file', type: file.type, getAsFile: () => file })),
|
||||
types: ['Files'],
|
||||
},
|
||||
});
|
||||
|
||||
await waitFor(() => expect(onReceiveFiles).toHaveBeenCalledOnce());
|
||||
expect(onReceiveFiles.mock.calls[0][0]).toEqual(files);
|
||||
});
|
||||
Reference in New Issue
Block a user