fix: Drapper mulitple should work

This commit is contained in:
zombiej 2019-08-30 17:16:10 +08:00 committed by 偏右
parent 4dfed8d0b7
commit 06d7f0deec
2 changed files with 30 additions and 0 deletions

View File

@ -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';

View File

@ -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();
});
});
});