Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AjaxUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class AjaxUploader extends Component<UploadProps> {
let acceptFiles = [...files].filter((file: RcFile) => attrAccept(file, accept));

if (multiple === false) {
acceptFiles = files.slice(0, 1);
acceptFiles = acceptFiles.slice(0, 1);
}

this.uploadFiles(acceptFiles);
Expand Down
25 changes: 25 additions & 0 deletions tests/uploader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,32 @@ describe('uploader', () => {
done();
}, 100);
});

it('drag unaccepted type files with multiple false to upload will not trigger onStart ', done => {
const { container } = render(<Upload {...props} multiple={false} />);

const input = container.querySelector('input')!;
const files = [
{
name: 'success.jpg',
toString() {
return this.name;
},
},
];
(files as any).item = (i: number) => files[i];

const mockStart = jest.fn();
handlers.onStart = mockStart;
fireEvent.drop(input, {
dataTransfer: { files },
});
setTimeout(() => {
expect(mockStart.mock.calls.length).toBe(0);
done();
}, 100);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是应该检测 beforeUpload 的触发情况?


it('drag files with multiple false', done => {
const { container } = render(<Upload {...props} multiple={false} />);
const input = container.querySelector('input')!;
Expand Down