mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
fix: Drapper mulitple should work
This commit is contained in:
parent
4dfed8d0b7
commit
06d7f0deec
@ -81,6 +81,12 @@ class Upload extends React.Component<UploadProps, UploadState> {
|
||||
|
||||
onStart = (file: RcFile) => {
|
||||
const { fileList } = this.state;
|
||||
const { multiple } = this.props;
|
||||
|
||||
if (!multiple && fileList.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const targetItem = fileToObject(file);
|
||||
targetItem.status = 'uploading';
|
||||
|
||||
|
@ -484,4 +484,28 @@ describe('Upload', () => {
|
||||
);
|
||||
errorSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('not allow multiple upload when multiple is false', done => {
|
||||
const onChange = jest.fn();
|
||||
|
||||
const wrapper = mount(
|
||||
<Upload
|
||||
fileList={[{ uid: '903', file: 'bamboo.png' }]}
|
||||
action="http://upload.com"
|
||||
onChange={onChange}
|
||||
multiple={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
wrapper.find('input').simulate('change', {
|
||||
target: {
|
||||
files: [{ file: 'light.png' }],
|
||||
},
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user