You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
58 lines
1.5 KiB
5 years ago
|
/* eslint-disable react/no-string-refs, react/prefer-es6-class */
|
||
|
import React from 'react';
|
||
|
import Upload from '..';
|
||
|
import mountTest from '../../../tests/shared/mountTest';
|
||
2 years ago
|
import { fireEvent, render, waitFor, act } from '../../../tests/utils';
|
||
2 years ago
|
import { setup, teardown } from './mock';
|
||
5 years ago
|
|
||
|
describe('Upload.Dragger', () => {
|
||
|
mountTest(Upload.Dragger);
|
||
|
|
||
|
beforeEach(() => setup());
|
||
|
afterEach(() => teardown());
|
||
|
|
||
2 years ago
|
it('support drag file with over style', async () => {
|
||
4 years ago
|
jest.useFakeTimers();
|
||
2 years ago
|
const { container: wrapper } = render(
|
||
5 years ago
|
<Upload.Dragger action="http://upload.com">
|
||
|
<div />
|
||
|
</Upload.Dragger>,
|
||
|
);
|
||
|
|
||
2 years ago
|
fireEvent.dragOver(wrapper.querySelector('.ant-upload-drag-container')!, {
|
||
5 years ago
|
target: {
|
||
|
files: [{ file: 'foo.png' }],
|
||
|
},
|
||
|
});
|
||
4 years ago
|
|
||
2 years ago
|
act(() => {
|
||
4 years ago
|
jest.runAllTimers();
|
||
|
});
|
||
|
|
||
2 years ago
|
await waitFor(() => {
|
||
|
expect(wrapper.querySelector('.ant-upload-drag')).toHaveClass('ant-upload-drag-hover');
|
||
|
});
|
||
4 years ago
|
|
||
|
jest.useRealTimers();
|
||
5 years ago
|
});
|
||
4 years ago
|
|
||
2 years ago
|
it('support onDrop when files are dropped onto upload area', async () => {
|
||
4 years ago
|
const onDrop = jest.fn();
|
||
2 years ago
|
const { container: wrapper } = render(
|
||
4 years ago
|
<Upload.Dragger onDrop={onDrop}>
|
||
|
<div />
|
||
|
</Upload.Dragger>,
|
||
|
);
|
||
|
|
||
2 years ago
|
fireEvent.drop(wrapper.querySelector('.ant-upload-drag-container')!, {
|
||
4 years ago
|
dataTransfer: {
|
||
|
files: [new File(['foo'], 'foo.png', { type: 'image/png' })],
|
||
|
},
|
||
|
});
|
||
|
|
||
2 years ago
|
await waitFor(() => {
|
||
|
expect(onDrop).toHaveBeenCalled();
|
||
|
});
|
||
4 years ago
|
});
|
||
5 years ago
|
});
|