mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
c34caad24c
* test: js => ts * test: add test * fix: fix eslint error * test: add test case * fix: fix test error * fix: fix eslint error * fix: fix eslint error * fix: eslint error fix * fix: fallback eslint config & add test case * test: add all test case * fix: bugfix * fix: bugFix * fix: bugFix * fix: bugFix * fix: lint * fix: add React.createRef * fix: add breadcrumbName in Routes * fix: any commit for restart ci/cd * fix: remove type * fix: test fix * fix: test fix * fix: add ts-ignore for id * test: add Icon test case * test: remove ts-ignore * test: add Icon test case
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
/* eslint-disable react/no-string-refs, react/prefer-es6-class */
|
|
import React from 'react';
|
|
import Upload from '..';
|
|
import mountTest from '../../../tests/shared/mountTest';
|
|
import { fireEvent, render, waitFor, act } from '../../../tests/utils';
|
|
import { setup, teardown } from './mock';
|
|
|
|
describe('Upload.Dragger', () => {
|
|
mountTest(Upload.Dragger);
|
|
|
|
beforeEach(() => setup());
|
|
afterEach(() => teardown());
|
|
|
|
it('support drag file with over style', async () => {
|
|
jest.useFakeTimers();
|
|
const { container: wrapper } = render(
|
|
<Upload.Dragger action="http://upload.com">
|
|
<div />
|
|
</Upload.Dragger>,
|
|
);
|
|
|
|
fireEvent.dragOver(wrapper.querySelector('.ant-upload-drag-container')!, {
|
|
target: {
|
|
files: [{ file: 'foo.png' }],
|
|
},
|
|
});
|
|
|
|
act(() => {
|
|
jest.runAllTimers();
|
|
});
|
|
|
|
await waitFor(() => {
|
|
expect(wrapper.querySelector('.ant-upload-drag')).toHaveClass('ant-upload-drag-hover');
|
|
});
|
|
|
|
jest.useRealTimers();
|
|
});
|
|
|
|
it('support onDrop when files are dropped onto upload area', async () => {
|
|
const onDrop = jest.fn();
|
|
const { container: wrapper } = render(
|
|
<Upload.Dragger onDrop={onDrop}>
|
|
<div />
|
|
</Upload.Dragger>,
|
|
);
|
|
|
|
fireEvent.drop(wrapper.querySelector('.ant-upload-drag-container')!, {
|
|
dataTransfer: {
|
|
files: [new File(['foo'], 'foo.png', { type: 'image/png' })],
|
|
},
|
|
});
|
|
|
|
await waitFor(() => {
|
|
expect(onDrop).toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|